Sha256: 5c3eef1d121a256cce317c782ad02a1056f53e85959268015e51758143b4f496

Contents?: true

Size: 980 Bytes

Versions: 10

Compression:

Stored size: 980 Bytes

Contents

require "spec_helper"

describe Detour::FlagInFlag do
  it { should be_a Detour::FlaggableFlag }

  it "validates uniquness of feature_id on flaggable" do
    user  = create :user
    flag  = create :flag_in_flag, flaggable: user
    flag2 = build  :flag_in_flag, flaggable: user, feature: flag.feature

    flag2.should_not be_valid
    flag2.errors.full_messages.should eq ["Feature has already been taken"]
  end

  describe "when creating" do
    let(:flag) { create :flag_in_flag }

    it "increments its feature's flag_in_count" do
      flag.reload.feature.flag_in_count_for(flag.flaggable_type.tableize).should eq 1
    end
  end

  describe "when destroying" do
    let!(:flag)  { create  :flag_in_flag }
    let!(:flag2) { create  :flag_in_flag, feature: flag.feature }

    before do
      flag2.destroy
    end

    it "decrements its feature's flag_in_count" do
      flag.reload.feature.flag_in_count_for(flag.flaggable_type.tableize).should eq 1
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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