Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Remove collection_spec #40

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Conversation

jeremyf
Copy link
Contributor

@jeremyf jeremyf commented Oct 4, 2023

In reviewing spec/models/collection_spec.rb and
hyrax-webapp/spec/models/collection_spec.rb; the specs in the Knapsack
are a subset of the specs in the collection_spec.rb

diff between knapsack and Hyku
❯ diff spec/models/collection_spec.rb hyrax-webapp/spec/models/collection_spec.rb
5a6,13
>   let(:user) { create(:user).tap { |u| u.add_role(:admin, Site.instance) } }
>   let(:account) { create(:account) }
>   let(:collection) { create(:collection, user: user) }
>
>   before do
>     Site.update(account: account)
>   end
>
14a23,73
>
>   describe "Featured Collections" do
>     before do
>       FeaturedCollection.create(collection_id: collection.id)
>     end
>
>     describe "#update" do
>       context "when collection is public" do
>         let(:collection) { create(:public_collection) }
>
>         it "does not remove the collection from featured collections" do
>           expect(collection).not_to receive(:remove_featured)
>           collection.update(title: ['New collection title'])
>         end
>       end
>
>       context "when collection is private" do
>         let(:collection) { create(:private_collection) }
>
>         it "removes collection from featured collections" do
>           expect(collection).to receive(:remove_featured)
>           collection.update(title: ['New collection title'])
>         end
>       end
>
>       context "when collection is changed from public to private" do
>         let(:collection) { create(:public_collection) }
>
>         it "removes collection from featured collections" do
>           expect(collection).to receive(:remove_featured)
>           collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
>           collection.save!
>         end
>       end
>     end
>
>     describe "#destroy" do
>       it 'deletes the featured collection after destroying the collection' do
>         expect(collection).to receive(:remove_featured)
>         collection.destroy
>       end
>     end
>
>     describe "#remove_featured" do
>       it 'removes collection from featured collections' do
>         expect(FeaturedCollection.where(collection_id: collection.id).count).to eq(1)
>         collection.remove_featured
>         expect(FeaturedCollection.where(collection_id: collection.id).count).to eq(0)
>       end
>     end
>   end

Related to:

In reviewing spec/models/collection_spec.rb and
hyrax-webapp/spec/models/collection_spec.rb; the specs in the Knapsack
are a subset of the specs in the collection_spec.rb

<details>
<summary>diff between knapsack and Hyku</summary>

```
❯ diff spec/models/collection_spec.rb hyrax-webapp/spec/models/collection_spec.rb
5a6,13
>   let(:user) { create(:user).tap { |u| u.add_role(:admin, Site.instance) } }
>   let(:account) { create(:account) }
>   let(:collection) { create(:collection, user: user) }
>
>   before do
>     Site.update(account: account)
>   end
>
14a23,73
>
>   describe "Featured Collections" do
>     before do
>       FeaturedCollection.create(collection_id: collection.id)
>     end
>
>     describe "#update" do
>       context "when collection is public" do
>         let(:collection) { create(:public_collection) }
>
>         it "does not remove the collection from featured collections" do
>           expect(collection).not_to receive(:remove_featured)
>           collection.update(title: ['New collection title'])
>         end
>       end
>
>       context "when collection is private" do
>         let(:collection) { create(:private_collection) }
>
>         it "removes collection from featured collections" do
>           expect(collection).to receive(:remove_featured)
>           collection.update(title: ['New collection title'])
>         end
>       end
>
>       context "when collection is changed from public to private" do
>         let(:collection) { create(:public_collection) }
>
>         it "removes collection from featured collections" do
>           expect(collection).to receive(:remove_featured)
>           collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
>           collection.save!
>         end
>       end
>     end
>
>     describe "#destroy" do
>       it 'deletes the featured collection after destroying the collection' do
>         expect(collection).to receive(:remove_featured)
>         collection.destroy
>       end
>     end
>
>     describe "#remove_featured" do
>       it 'removes collection from featured collections' do
>         expect(FeaturedCollection.where(collection_id: collection.id).count).to eq(1)
>         collection.remove_featured
>         expect(FeaturedCollection.where(collection_id: collection.id).count).to eq(0)
>       end
>     end
>   end
```

</details>

Related to:

- https://github.com/scientist-softserv/adventist-dl/issues/538
@jeremyf jeremyf merged commit 5b922be into main Oct 4, 2023
2 checks passed
@jeremyf jeremyf deleted the spec-models-collection_spec.rb branch October 4, 2023 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants