Skip to content

Instantly share code, notes, and snippets.

@jraczak
Created February 9, 2015 00:41
Show Gist options
  • Save jraczak/09581f190929b16861c7 to your computer and use it in GitHub Desktop.
Save jraczak/09581f190929b16861c7 to your computer and use it in GitHub Desktop.
Recent activity spec for the user profile page
describe "#recent_activity" do
subject { FactoryGirl.create(:user) }
let!(:unowned_score) { FactoryGirl.create(:venue_score) }
let!(:unowned_tip) { FactoryGirl.create(:tip) }
let!(:unowned_list) { FactoryGirl.create(:list) }
context "when venue scores have been submitted" do
let!(:venue_score) { FactoryGirl.create(:venue_score, user: subject) }
it "should include venue scores" do
subject.recent_activity.any? { |activity| activity.class == VenueScore }.should == true
end
it "should only include its own venue scores" do
subject.recent_activity.include?(unowned_score).should be_false
subject.recent_activity.include?(venue_score).should be_true
end
end
context "when no venue scores have been submitted" do
it "should not include venue scores" do
subject.recent_activity.any? { |activity| activity.class == VenueScore }.should == false
end
end
context "when tips have been submitted" do
let!(:tip) { FactoryGirl.create(:tip, user: subject) }
it "should include tips" do
subject.recent_activity.any? { |activity| activity.class == Tip }.should == true
end
it "should only include its own tips" do
subject.recent_activity.include?(unowned_tip).should be_false
subject.recent_activity.include?(tip).should be_true
end
end
context "when no tips have been submitted" do
it "should not include tips" do
subject.recent_activity.any? { |activity| activity.class == Tip }.should == false
end
end
context "when lists have been created" do
let!(:list) { FactoryGirl.create(:list, user: subject) }
it "should include lists" do
subject.recent_activity.any? { |activity| activity.class == List }.should == true
end
it "should only include its own lists" do
subject.recent_activity.include?(unowned_list).should be_false
subject.recent_activity.include?(list).should be_true
end
end
context "when no lists have been created" do
it "should not include lists" do
subject.recent_activity.any? { |activity| activity.class == List }.should == false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment