Sha256: 80cc66b451e3b3ecab02a926903418c5fb4e67bc612e025c39af8bac345b4026

Contents?: true

Size: 785 Bytes

Versions: 10

Compression:

Stored size: 785 Bytes

Contents

require "spec_helper"

describe Detour::FlaggableFlag do
  it { should belong_to :flaggable }
  it { should validate_presence_of :flaggable }
  it { should allow_mass_assignment_of :flaggable }

  describe "before validating" do
    it "sets its flaggable" do
      feature = create(:feature)
      user    = create(:user)
      flag    = create(:flag_in_flag, flaggable: nil, feature: feature, flaggable_key: user.id, flaggable_type: "User")
      flag.flaggable_id.should eq user.id
    end

    context "when the flaggable is not found" do
      let(:flag) { build :flag_in_flag, flaggable: nil, flaggable_key: 1, flaggable_type: "User" }

      it "is invalidated" do
        flag.valid?
        flag.errors["User"].should eq ['"1" could not be found']
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
detour-0.0.15 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.14 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.13 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.12 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.11 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.10 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.9 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.7 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.6 spec/models/detour/flaggable_flag_spec.rb
detour-0.0.5 spec/models/detour/flaggable_flag_spec.rb