Skip to content

Commit ce93160

Browse files
committed
Create demo_work
* generate the DemoWork work type following Hyrax README instructions Test with * start server and test at localhost:3000 * add a user -- Login -> Sign up * add a demo work -- Works -> New Work (should show Add New Demo Work form)
1 parent f24b1a6 commit ce93160

File tree

13 files changed

+122
-0
lines changed

13 files changed

+122
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
module Hyrax
4+
module Actors
5+
class DemoWorkActor < Hyrax::Actors::BaseActor
6+
end
7+
end
8+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
4+
module Hyrax
5+
class DemoWorksController < ApplicationController
6+
# Adds Hyrax behaviors to the controller.
7+
include Hyrax::WorksControllerBehavior
8+
include Hyrax::BreadcrumbsForWorks
9+
self.curation_concern_type = DemoWork
10+
end
11+
end

app/forms/hyrax/demo_work_form.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
module Hyrax
4+
class DemoWorkForm < Hyrax::Forms::WorkForm
5+
self.model_class = ::DemoWork
6+
self.terms += [:resource_type]
7+
end
8+
end

app/models/demo_work.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
class DemoWork < ActiveFedora::Base
4+
include ::Hyrax::WorkBehavior
5+
include ::Hyrax::BasicMetadata
6+
# Change this to restrict which works can be added as a child.
7+
# self.valid_child_concerns = []
8+
validates :title, presence: { message: 'Your work must have a title.' }
9+
10+
self.human_readable_type = 'Demo Work'
11+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<%# This is a search result view %>
2+
<%= render 'catalog/document', document: demo_work, document_counter: demo_work_counter %>

config/initializers/hyrax.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Hyrax.config do |config|
2+
# Injected via `rails g hyrax:work DemoWork`
3+
config.register_curation_concern :demo_work
24
# Register roles that are expected by your implementation.
35
# @see Hyrax::RoleRegistry for additional details.
46
# @note there are magical roles as defined in Hyrax::RoleRegistry::MAGIC_ROLES

config/locales/demo_work.en.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
en:
2+
hyrax:
3+
icons:
4+
demo_work: 'fa fa-file-text-o'
5+
select_type:
6+
demo_work:
7+
name: "Demo Work"
8+
description: "Demo work works"

config/locales/demo_work.es.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
es:
2+
hyrax:
3+
icons:
4+
demo_work: 'fa fa-file-text-o'
5+
select_type:
6+
demo_work:
7+
# TODO: translate `human_name` into Spanish
8+
name: "Demo Work"
9+
# TODO: translate `human_name` into Spanish
10+
description: "Demo work trabajos"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
require 'rails_helper'
4+
5+
RSpec.describe Hyrax::Actors::DemoWorkActor do
6+
it "has tests" do
7+
skip "Add your tests here"
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
require 'rails_helper'
4+
5+
RSpec.describe Hyrax::DemoWorksController do
6+
it "has tests" do
7+
skip "Add your tests here"
8+
end
9+
end
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
require 'rails_helper'
4+
include Warden::Test::Helpers
5+
6+
RSpec.feature 'Create a DemoWork' do
7+
context 'a logged in user' do
8+
let(:user_attributes) do
9+
{ email: '[email protected]' }
10+
end
11+
let(:user) do
12+
User.new(user_attributes) { |u| u.save(validate: false) }
13+
end
14+
15+
before do
16+
login_as user
17+
end
18+
19+
scenario do
20+
visit new_curation_concerns_demo_work_path
21+
fill_in 'Title', with: 'Test DemoWork'
22+
click_button 'Create DemoWork'
23+
expect(page).to have_content 'Test DemoWork'
24+
end
25+
end
26+
end
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
require 'rails_helper'
4+
5+
RSpec.describe Hyrax::DemoWorkForm do
6+
it "has tests" do
7+
skip "Add your tests here"
8+
end
9+
end

spec/models/demo_work_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Generated via
2+
# `rails generate hyrax:work DemoWork`
3+
require 'rails_helper'
4+
5+
RSpec.describe DemoWork do
6+
it "has tests" do
7+
skip "Add your tests here"
8+
end
9+
end

0 commit comments

Comments
 (0)