Skip to content

Commit

Permalink
Merge pull request #529 from pulibrary/boxless-with-vocabs
Browse files Browse the repository at this point in the history
Fixing controlled vocabularies for boxless folders
  • Loading branch information
Trey Pendragon authored Nov 6, 2017
2 parents 6c4f3c2 + 5c1fe78 commit a3c704b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
13 changes: 2 additions & 11 deletions app/controllers/ephemera_folders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,8 @@ def parent_resource
find_resource(params[:parent_id])
end

# TODO: this could return a project in a boxless setup?
def ephemera_box
@ephemera_box ||= params[:parent_id] ? parent_resource.decorate : resource.decorate.ephemera_box
rescue => e
Rails.logger.warn e
nil
end

# TODO: seems like this could fail in a boxless folder / project setup
def fields
@fields ||= ephemera_box.ephemera_project.fields
@fields ||= ephemera_project.fields
rescue => e
Rails.logger.warn e
[]
Expand All @@ -100,6 +91,6 @@ def top_languages

# returns decorated project
def ephemera_project
ephemera_box ? ephemera_box.ephemera_project : parent_resource.decorate
parent_resource.is_a?(EphemeraProject) ? parent_resource.decorate : parent_resource.decorate.ephemera_project
end
end
24 changes: 24 additions & 0 deletions spec/features/ephemera_vocabularies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@
expect(page.all(:css, '.dropdown-menu.open').first.all(:css, 'a:last-child').last).to have_content 'test term'
end
end

context 'when users have added a field and boxless' do
let(:ephemera_field) do
res = FactoryGirl.create_for_repository(:ephemera_field, member_of_vocabulary_id: ephemera_vocabulary.id)
adapter.persister.save(resource: res)
end

before do
res = FactoryGirl.create_for_repository(:ephemera_term)
res.member_of_vocabulary_id = ephemera_vocabulary.id
adapter.persister.save(resource: res)

ephemera_project.member_ids = [ephemera_field.id]
adapter.persister.save(resource: ephemera_project)
end

scenario 'users can add folder metadata using controlled vocabularies' do
visit parent_new_ephemera_box_path(parent_id: ephemera_project.id)

expect(page).to have_selector('.ephemera_folder_language button.dropdown-toggle')
page.find(:css, '[data-id="ephemera_folder_language"]').click
expect(page.all(:css, '.dropdown-menu.open').first.all(:css, 'a:last-child').last).to have_content 'test term'
end
end
end

scenario 'users can create controlled vocabularies' do
Expand Down

0 comments on commit a3c704b

Please sign in to comment.