Sha256: 45e4e2669a168b06b9f4404890aa6ebdaa1e258d5a595834cb1c2ce2caf69e39

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

require "spec_helper"

describe Detour::ActsAsFlaggable do
  subject { User.new }

  it { should have_many :flaggable_flags }
  it { should have_many :opt_out_flags }
  it { should have_many(:features).through(:flaggable_flags) }

  it "includes Detour::Flaggable" do
    subject.class.ancestors.should include Detour::Flaggable
  end

  describe "#acts_as_flaggable" do
    context "when given a :find_by parameter" do
      class Foo < ActiveRecord::Base
        acts_as_flaggable find_by: :email
      end

      it "sets the appropriate class variable on the class" do
        Foo.instance_variable_get("@detour_flaggable_find_by").should eq :email
      end
    end

    context "when not given a :find_by parameter" do
      it "uses the default :id value for flaggable_find_by" do
        User.instance_variable_get("@detour_flaggable_find_by").should eq :id
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
detour-0.0.1 spec/lib/active_record/rollout/acts_as_flaggable_spec.rb