Sha256: 7274aeb2449590289f9b8dd18a0f4da9e8d708e283a3b843f7282ba3763626cf

Contents?: true

Size: 939 Bytes

Versions: 9

Compression:

Stored size: 939 Bytes

Contents

require "spec_helper"

describe Detour::DatabaseGroupFlag do
  it { should validate_presence_of :group_id }
  it { should validate_presence_of :flaggable_type }
  it { should validate_uniqueness_of(:feature_id).scoped_to(:group_id) }

  it { should allow_mass_assignment_of :group_id }

  it { should belong_to :group }
  it { should have_many(:memberships).through(:group) }

  describe "#members" do
    let(:flag) { create :database_group_flag }
    let!(:membership) { create :membership, group: flag.group }

    it "uses the flaggable class's table name for its SQL find" do
      User.should_receive(:table_name)
      flag.members
    end

    it "returns its membership members" do
      flag.members.should eq [membership.member]
    end
  end

  describe "#group_name" do
    let(:flag) { create :database_group_flag }

    it "returns the name of the group" do
      flag.group_name.should eq flag.group.name
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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