Sha256: 81cb813c7f02588fcb916243077ef31bb8a748fd35335ad63a74828bb3b98d40
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true require "rails_helper" module Archangel RSpec.describe Collection, type: :model do context "callbacks" do it { is_expected.to callback(:parameterize_slug).before(:validation) } it { is_expected.to callback(:column_reset).after(:destroy) } end context "validations" do it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:slug) } it "has a unique slug scoped to Site" do resource = build(:collection) expect(resource) .to validate_uniqueness_of(:slug).scoped_to(:site_id).case_insensitive end end context "associations" do it { is_expected.to belong_to(:site) } it { is_expected.to have_many(:entries) } it { is_expected.to have_many(:fields) } end context "#to_param" do it "uses `slug` as the identifier for routes" do resource = build(:collection, slug: "foo") expect(resource.to_param).to eq("foo") end end context "#column_reset" do before { ::Timecop.freeze } after { ::Timecop.return } it "resets `slug` to `slug` + current time" do resource = create(:collection) slug = resource.slug resource.destroy! expect(resource.slug).to eq "#{Time.current.to_i}_#{slug}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
archangel-0.0.6 | spec/models/archangel/collection_spec.rb |