diff --git a/spec/views/collections/edit_fields/_based_near.html.erb_spec.rb b/spec/views/collections/edit_fields/_based_near.html.erb_spec.rb index 8e07541c88..2726afe463 100644 --- a/spec/views/collections/edit_fields/_based_near.html.erb_spec.rb +++ b/spec/views/collections/edit_fields/_based_near.html.erb_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe 'collections/edit_fields/_based_near.html.erb', type: :view do - let(:collection) { Collection.new } - let(:form) { Hyrax::Forms::CollectionForm.new(collection, nil, controller) } + let(:collection) { build :collection_resource } + let(:form) { Hyrax::Forms::ResourceForm.for(collection) } let(:form_template) do %( <%= simple_form_for @form, url: [hyrax, :dashboard, @form] do |f| %> diff --git a/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb b/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb index 7b65f97f25..add7a3db95 100644 --- a/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb +++ b/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb @@ -3,33 +3,35 @@ let(:user) { create(:user) } let(:work) do - mock_model(GenericWork, label: 'One Hundred Years of Solitude', date_uploaded: '1999', - collection?: true, visibility: 'open', - title: ['One Hundred Years of Solitude'], - depositor: user, - edit_groups: [], - creator: ["ggm"]) + build(:monograph, + label: 'One Hundred Years of Solitude', + date_uploaded: '1999', + visibility_setting: 'open', + title: 'One Hundred Years of Solitude', + depositor: user.user_key, + edit_groups: [], + creator: ["ggm"]) end - let(:collection) { mock_model(Collection, title: 'My awesome collection', members: [work]) } + let(:solr_doc) { ::SolrDocument.new(Hyrax::ValkyrieIndexer.for(resource: work).to_solr) } + + let(:collection) { build(:hyrax_collection, title: 'My awesome collection', members: [work]) } context 'when not logged in' do before do view.blacklight_config = Blacklight::Configuration.new assign(:presenter, collection) allow(view).to receive(:current_user).and_return(nil) - allow(work).to receive(:title_or_label).and_return("One Hundred Years of Solitude") - allow(work).to receive(:edit_people).and_return([]) allow(view).to receive(:render_other_collection_links).and_return([]) end it "renders collections links" do - render('hyrax/collections/show_document_list_row.html.erb', document: work) + render('hyrax/collections/show_document_list_row.html.erb', document: solr_doc) expect(rendered).not_to have_content 'My awesome collection' end it "renders works" do - render('hyrax/collections/show_document_list_row.html.erb', document: work) + render('hyrax/collections/show_document_list_row.html.erb', document: solr_doc) expect(rendered).to have_content 'One Hundred Years of Solitude' expect(rendered).not_to have_content('Edit Access:') end diff --git a/spec/views/hyrax/dashboard/collections/_form.html.erb_spec.rb b/spec/views/hyrax/dashboard/collections/_form.html.erb_spec.rb index d9f43dae5f..584be8b0ce 100644 --- a/spec/views/hyrax/dashboard/collections/_form.html.erb_spec.rb +++ b/spec/views/hyrax/dashboard/collections/_form.html.erb_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe 'hyrax/dashboard/collections/_form.html.erb', type: :view do - let(:collection) { Collection.new } - let(:collection_form) { Hyrax::Forms::CollectionForm.new(collection, double, double) } + let(:collection) { build :collection_resource } + let(:collection_form) { Hyrax::Forms::ResourceForm.for(collection) } let(:banner_info) { { file: "banner.gif", alttext: "Banner alt text" } } let(:logo_info) { [{ file: "logo.gif", alttext: "Logo alt text", linkurl: "http://abc.com" }] } diff --git a/spec/views/hyrax/dashboard/collections/_form_discovery.erb_spec.rb b/spec/views/hyrax/dashboard/collections/_form_discovery.erb_spec.rb index 917e25b5a7..f4fd5fbb8d 100644 --- a/spec/views/hyrax/dashboard/collections/_form_discovery.erb_spec.rb +++ b/spec/views/hyrax/dashboard/collections/_form_discovery.erb_spec.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true RSpec.describe 'hyrax/dashboard/collections/_form_discovery.html.erb', type: :view do - let(:collection) { Collection.new } - let(:form) { Hyrax::Forms::CollectionForm.new(collection, double, double) } let(:f) do view.simple_form_for(form, url: '/update') do |fs_form| return fs_form @@ -14,27 +12,32 @@ render end - context "collection has open access" do - let(:visibility) { 'open' } + context 'with AF Collection', :active_fedora do + let(:collection) { Collection.new } + let(:form) { Hyrax::Forms::CollectionForm.new(collection, double, double) } - it "check open access is set" do - expect(rendered).to have_selector('input[type=radio][name="collection[visibility]"][value=open][checked]') + context "collection has open access" do + let(:visibility) { 'open' } + + it "check open access is set" do + expect(rendered).to have_selector('input[type=radio][name="collection[visibility]"][value=open][checked]') + end end - end - context "collection has authenticated access" do - let(:visibility) { 'authenticated' } + context "collection has authenticated access" do + let(:visibility) { 'authenticated' } - it "check authenticated access is set" do - expect(rendered).to have_selector('input[type=radio][name="collection[visibility]"][value=authenticated][checked]') + it "check authenticated access is set" do + expect(rendered).to have_selector('input[type=radio][name="collection[visibility]"][value=authenticated][checked]') + end end - end - context "collection has restricted access" do - let(:visibility) { 'restricted' } + context "collection has restricted access" do + let(:visibility) { 'restricted' } - it "restricted access is set" do - expect(rendered).to have_selector('input[type=radio][name="collection[visibility]"][value=restricted][checked]') + it "restricted access is set" do + expect(rendered).to have_selector('input[type=radio][name="collection[visibility]"][value=restricted][checked]') + end end end diff --git a/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb b/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb index b1b9000044..ffe0cb227a 100644 --- a/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb +++ b/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb @@ -24,7 +24,7 @@ allow(view) .to receive(:available_parent_collections_data) .with(collection: presenter) - .and_return([mock_model(Collection)]) + .and_return([build(:hyrax_collection)]) stub_template 'hyrax/my/_collection_action_menu.html.erb' => 'actions' end diff --git a/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb b/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb index 5c8efe7af9..7435d0900e 100644 --- a/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb +++ b/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb @@ -3,33 +3,35 @@ let(:user) { create(:user) } let(:work) do - mock_model(GenericWork, label: 'One Hundred Years of Solitude', date_uploaded: '1999', - collection?: true, visibility: 'open', - title: ['One Hundred Years of Solitude'], - depositor: user, - edit_groups: [], - creator: ["ggm"]) + build(:monograph, + label: 'One Hundred Years of Solitude', + date_uploaded: '1999', + visibility_setting: 'open', + title: 'One Hundred Years of Solitude', + depositor: user.user_key, + edit_groups: [], + creator: ["ggm"]) end - let(:collection) { mock_model(Collection, title: 'My awesome collection', members: [work]) } + let(:solr_doc) { ::SolrDocument.new(Hyrax::ValkyrieIndexer.for(resource: work).to_solr) } + + let(:collection) { build(:hyrax_collection, title: 'My awesome collection', members: [work]) } context 'when not logged in' do before do view.blacklight_config = Blacklight::Configuration.new assign(:presenter, collection) allow(view).to receive(:current_user).and_return(nil) - allow(work).to receive(:title_or_label).and_return("One Hundred Years of Solitude") - allow(work).to receive(:edit_people).and_return([]) allow(view).to receive(:render_other_collection_links).and_return([]) end it "renders collections links" do - render('show_document_list_row', document: work) + render('show_document_list_row', document: solr_doc) expect(rendered).not_to have_content 'My awesome collection' end it "renders works" do - render('show_document_list_row', document: work) + render('show_document_list_row', document: solr_doc) expect(rendered).to have_content 'One Hundred Years of Solitude' expect(rendered).to have_content('Edit Access:') end diff --git a/spec/views/hyrax/dashboard/collections/edit.html.erb_spec.rb b/spec/views/hyrax/dashboard/collections/edit.html.erb_spec.rb index 7587fbd961..7afffce57b 100644 --- a/spec/views/hyrax/dashboard/collections/edit.html.erb_spec.rb +++ b/spec/views/hyrax/dashboard/collections/edit.html.erb_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true RSpec.describe 'hyrax/dashboard/collections/edit.html.erb', type: :view do let(:collection_type) { stub_model(Hyrax::CollectionType) } - let(:collection) { stub_model(Collection, id: 'xyz123z4', title: ["Make Collections Great Again"]) } - let(:form) { Hyrax::Forms::CollectionForm.new(collection, double, double) } + let(:collection) { build :hyrax_collection } + let(:form) { Hyrax::Forms::ResourceForm.for(collection) } before do assign(:collection, collection)