Skip to content

Commit

Permalink
Added logger DEBUG level to dev env. Created initial work type.
Browse files Browse the repository at this point in the history
  • Loading branch information
svogtunh committed Nov 12, 2019
1 parent bdacc13 commit d4aa959
Show file tree
Hide file tree
Showing 21 changed files with 246 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/actors/hyrax/actors/work_actor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated via
# `rails generate hyrax:work Work`
module Hyrax
module Actors
class WorkActor < Hyrax::Actors::BaseActor
end
end
end
14 changes: 14 additions & 0 deletions app/controllers/hyrax/works_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated via
# `rails generate hyrax:work Work`
module Hyrax
# Generated controller for Work
class WorksController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::Work

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::WorkPresenter
end
end
9 changes: 9 additions & 0 deletions app/forms/hyrax/work_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work Work`
module Hyrax
# Generated form for Work
class WorkForm < Hyrax::Forms::WorkForm
self.model_class = ::Work
self.terms += [:resource_type]
end
end
18 changes: 18 additions & 0 deletions app/indexers/work_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated via
# `rails generate hyrax:work Work`
class WorkIndexer < Hyrax::WorkIndexer
# This indexes the default metadata. You can remove it if you want to
# provide your own metadata and indexing.
include Hyrax::IndexesBasicMetadata

# Fetch remote labels for based_near. You can remove this if you don't want
# this behavior
include Hyrax::IndexesLinkedMetadata

# Uncomment this block if you want to add custom indexing behavior:
# def generate_solr_document
# super.tap do |solr_doc|
# solr_doc['my_custom_field_ssim'] = object.my_custom_property
# end
# end
end
14 changes: 14 additions & 0 deletions app/models/work.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated via
# `rails generate hyrax:work Work`
class Work < ActiveFedora::Base
include ::Hyrax::WorkBehavior

self.indexer = WorkIndexer
# Change this to restrict which works can be added as a child.
# self.valid_child_concerns = []
validates :title, presence: { message: 'Your work must have a title.' }

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
include ::Hyrax::BasicMetadata
end
6 changes: 6 additions & 0 deletions app/presenters/hyrax/work_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated via
# `rails generate hyrax:work Work`
module Hyrax
class WorkPresenter < Hyrax::WorkShowPresenter
end
end
2 changes: 2 additions & 0 deletions app/views/hyrax/works/_work.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%# This is a search result view %>
<%= render 'catalog/document', document: work, document_counter: work_counter %>
2 changes: 2 additions & 0 deletions config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Hyrax.config do |config|
# Injected via `rails g hyrax:work Work`
config.register_curation_concern :work
# Register roles that are expected by your implementation.
# @see Hyrax::RoleRegistry for additional details.
# @note there are magical roles as defined in Hyrax::RoleRegistry::MAGIC_ROLES
Expand Down
8 changes: 8 additions & 0 deletions config/locales/work.de.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
de:
hyrax:
icons:
work: 'fa fa-file-text-o'
select_type:
work:
description: "Work Werke"
name: "Work"
8 changes: 8 additions & 0 deletions config/locales/work.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
en:
hyrax:
icons:
work: 'fa fa-file-text-o'
select_type:
work:
description: "Work works"
name: "Work"
10 changes: 10 additions & 0 deletions config/locales/work.es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
es:
hyrax:
icons:
work: 'fa fa-file-text-o'
select_type:
work:
# TODO: translate `human_name` into Spanish
description: "Work trabajos"
name: "Work"
# TODO: translate `human_name` into Spanish
8 changes: 8 additions & 0 deletions config/locales/work.fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fr:
hyrax:
icons:
work: 'fa fa-file-text-o'
select_type:
work:
description: "Work œuvres"
name: "Work"
8 changes: 8 additions & 0 deletions config/locales/work.it.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
it:
hyrax:
icons:
work: 'fa fa-file-text-o'
select_type:
work:
description: "Work opere"
name: "Work"
8 changes: 8 additions & 0 deletions config/locales/work.pt-BR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pt-BR:
hyrax:
icons:
work: 'fa fa-file-text-o'
select_type:
work:
description: "Work obras"
name: "Work"
10 changes: 10 additions & 0 deletions config/locales/work.zh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
zh:
hyrax:
icons:
work: 'fa fa-file-text-o'
select_type:
work:
# TODO: translate `human_name` into Chinese
description: "Work 作品"
name: "Work"
# TODO: translate `human_name` into Chinese
9 changes: 9 additions & 0 deletions spec/actors/hyrax/actors/work_actor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work Work`
require 'rails_helper'

RSpec.describe Hyrax::Actors::WorkActor do
it "has tests" do
skip "Add your tests here"
end
end
9 changes: 9 additions & 0 deletions spec/controllers/hyrax/works_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work Work`
require 'rails_helper'

RSpec.describe Hyrax::WorksController do
it "has tests" do
skip "Add your tests here"
end
end
68 changes: 68 additions & 0 deletions spec/features/create_work_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated via
# `rails generate hyrax:work Work`
require 'rails_helper'
include Warden::Test::Helpers

# NOTE: If you generated more than one work, you have to set "js: true"
RSpec.feature 'Create a Work', js: false do
context 'a logged in user' do
let(:user_attributes) do
{ email: '[email protected]' }
end
let(:user) do
User.new(user_attributes) { |u| u.save(validate: false) }
end
let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id) }
let(:workflow) { Sipity::Workflow.create!(active: true, name: 'test-workflow', permission_template: permission_template) }

before do
# Create a single action that can be taken
Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow)

# Grant the user access to deposit into the admin set.
Hyrax::PermissionTemplateAccess.create!(
permission_template_id: permission_template.id,
agent_type: 'user',
agent_id: user.user_key,
access: 'deposit'
)
login_as user
end

scenario do
visit '/dashboard'
click_link "Works"
click_link "Add new work"

# If you generate more than one work uncomment these lines
# choose "payload_concern", option: "Work"
# click_button "Create work"

expect(page).to have_content "Add New Work"
click_link "Files" # switch tab
expect(page).to have_content "Add files"
expect(page).to have_content "Add folder"
within('span#addfiles') do
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/image.jp2", visible: false)
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/jp2_fits.xml", visible: false)
end
click_link "Descriptions" # switch tab
fill_in('Title', with: 'My Test Work')
fill_in('Creator', with: 'Doe, Jane')
select('In Copyright', from: 'Rights statement')

# With selenium and the chrome driver, focus remains on the
# select box. Click outside the box so the next line can't find
# its element
find('body').click
choose('work_visibility_open')
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
check('agreement')

click_on('Save')
expect(page).to have_content('My Test Work')
expect(page).to have_content "Your files are being processed by Hyrax in the background."
end
end
end
9 changes: 9 additions & 0 deletions spec/forms/hyrax/work_form_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work Work`
require 'rails_helper'

RSpec.describe Hyrax::WorkForm do
it "has tests" do
skip "Add your tests here"
end
end
9 changes: 9 additions & 0 deletions spec/models/work_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work Work`
require 'rails_helper'

RSpec.describe Work do
it "has tests" do
skip "Add your tests here"
end
end
9 changes: 9 additions & 0 deletions spec/presenters/hyrax/work_presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work Work`
require 'rails_helper'

RSpec.describe Hyrax::WorkPresenter do
it "has tests" do
skip "Add your tests here"
end
end

0 comments on commit d4aa959

Please sign in to comment.