spec/models/generic_work_spec.rb in sufia-7.0.0.beta4 vs spec/models/generic_work_spec.rb in sufia-7.0.0.rc1

- old
+ new

@@ -47,9 +47,33 @@ w.destroy expect(Trophy.where(work_id: w.id).count).to eq 0 end end + describe "featured works" do + let(:work) { create(:public_work) } + before { FeaturedWork.create(work_id: work.id) } + + subject { work } + it { is_expected.to be_featured } + + context "when a previously featured work is deleted" do + it "deletes the featured work as well" do + expect { work.destroy }.to change { FeaturedWork.all.count }.from(1).to(0) + end + end + + context "when the work becomes private" do + it "deletes the featured work" do + expect do + work.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE + work.save! + end.to change { FeaturedWork.all.count }.from(1).to(0) + expect(work).not_to be_featured + end + end + end + describe "metadata" do it "has descriptive metadata" do expect(subject).to respond_to(:relative_path) expect(subject).to respond_to(:depositor) expect(subject).to respond_to(:related_url)