diff --git a/test/acts_as_followable_test.rb b/test/acts_as_followable_test.rb index 77a06b7..5f95412 100644 --- a/test/acts_as_followable_test.rb +++ b/test/acts_as_followable_test.rb @@ -20,6 +20,8 @@ class ActsAsFollowableTest < ActiveSupport::TestCase @jon = FactoryGirl.create(:jon) @oasis = FactoryGirl.create(:oasis) @metallica = FactoryGirl.create(:metallica) + @green_day = FactoryGirl.create(:green_day) + @blink_182 = FactoryGirl.create(:blink_182) @sam.follow(@jon) end @@ -225,6 +227,20 @@ class ActsAsFollowableTest < ActiveSupport::TestCase end end + context "followers_with_sti" do + setup do + @sam.follow(@green_day) + @sam.follow(@blink_182) + end + + should "return the followers for given type" do + assert_equal @sam.follows_by_type('Band').first.followable, @green_day.becomes(Band) + assert_equal @sam.follows_by_type('Band').second.followable, @blink_182.becomes(Band) + assert @green_day.followers_by_type('User').include?(@sam) + assert @blink_182.followers_by_type('User').include?(@sam) + end + end + context "method_missing" do setup do @sam.follow(@oasis) diff --git a/test/dummy30/app/models/band/punk.rb b/test/dummy30/app/models/band/punk.rb new file mode 100644 index 0000000..4edb940 --- /dev/null +++ b/test/dummy30/app/models/band/punk.rb @@ -0,0 +1,4 @@ +class Band::Punk < Band + validates_presence_of :name + acts_as_followable +end diff --git a/test/dummy30/app/models/band/punk/pop_punk.rb b/test/dummy30/app/models/band/punk/pop_punk.rb new file mode 100644 index 0000000..b4d4285 --- /dev/null +++ b/test/dummy30/app/models/band/punk/pop_punk.rb @@ -0,0 +1,4 @@ +class Band::Punk::PopPunk < Band::Punk + validates_presence_of :name + acts_as_followable +end diff --git a/test/factories/bands.rb b/test/factories/bands.rb index 3e6eb9b..3e99de1 100644 --- a/test/factories/bands.rb +++ b/test/factories/bands.rb @@ -6,4 +6,12 @@ factory :metallica, :class => Band do |b| b.name 'Metallica' end + + factory :green_day, :class => Band::Punk do |b| + b.name 'Green Day' + end + + factory :blink_182, :class => Band::Punk::PopPunk do |b| + b.name 'Blink 182' + end end