Sha256: 3d86422c6271a7187e78e598b27d887dfd378d3816472bccdeab290ac3bf2929

Contents?: true

Size: 1.23 KB

Versions: 23

Compression:

Stored size: 1.23 KB

Contents

describe FeaturedWork, type: :model do
  let(:feature) { described_class.create(work_id: "99") }

  it "has a file" do
    expect(feature.work_id).to eq "99"
  end

  it "does not allow six features" do
    5.times do |n|
      expect(described_class.create(work_id: n.to_s)).not_to be_new_record
    end
    described_class.create(work_id: "6").tap do |sixth|
      expect(sixth).to be_new_record
      expect(sixth.errors.full_messages).to eq ["Limited to 5 featured works."]
    end
    expect(described_class.count).to eq 5
  end

  describe "can_create_another?" do
    subject { described_class }
    context "when none exist" do
      describe '#can_create_another?' do
        subject { super().can_create_another? }
        it { is_expected.to be true }
      end
    end
    context "when five exist" do
      before do
        5.times do |n|
          described_class.create(work_id: n.to_s)
        end
      end

      describe '#can_create_another?' do
        subject { super().can_create_another? }
        it { is_expected.to be false }
      end
    end
  end

  describe "#order" do
    subject { described_class.new(order: 5) }

    describe '#order' do
      subject { super().order }
      it { is_expected.to eq 5 }
    end
  end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
hyrax-1.1.1 spec/models/featured_work_spec.rb
hyrax-1.1.0 spec/models/featured_work_spec.rb
sufia-7.4.1 spec/models/featured_work_spec.rb
hyrax-1.0.5 spec/models/featured_work_spec.rb
sufia-7.4.0 spec/models/featured_work_spec.rb
hyrax-1.0.4 spec/models/featured_work_spec.rb
hyrax-1.0.3 spec/models/featured_work_spec.rb
hyrax-1.0.2 spec/models/featured_work_spec.rb
hyrax-1.0.1 spec/models/featured_work_spec.rb
hyrax-1.0.0.rc2 spec/models/featured_work_spec.rb
sufia-7.3.1 spec/models/featured_work_spec.rb
hyrax-1.0.0.rc1 spec/models/featured_work_spec.rb
sufia-7.3.0 spec/models/featured_work_spec.rb
sufia-7.3.0.rc3 spec/models/featured_work_spec.rb
sufia-7.3.0.rc2 spec/models/featured_work_spec.rb
sufia-7.3.0.rc1 spec/models/featured_work_spec.rb
test_hyrax-0.0.1.alpha spec/models/featured_work_spec.rb
sufia-7.2.0 spec/models/featured_work_spec.rb
sufia-7.1.0 spec/models/featured_work_spec.rb
sufia-7.0.0 spec/models/featured_work_spec.rb