Find enterprise groups on the front page

This commit is contained in:
Rohan Mitchell
2013-10-30 13:54:11 +11:00
parent 2d80490d41
commit 7f6f725e02
2 changed files with 11 additions and 0 deletions

View File

@@ -2,4 +2,6 @@ class EnterpriseGroup < ActiveRecord::Base
has_and_belongs_to_many :enterprises
validates :name, presence: true
scope :on_front_page, where(on_front_page: true)
end

View File

@@ -28,4 +28,13 @@ describe EnterpriseGroup do
# eg.reload.image.should == image
# end
end
describe "scopes" do
it "finds enterprise groups on the front page" do
eg1 = create(:enterprise_group, on_front_page: true)
eg2 = create(:enterprise_group, on_front_page: false)
EnterpriseGroup.on_front_page.should == [eg1]
end
end
end