Created
          February 9, 2015 00:41 
        
      - 
      
- 
        Save jraczak/09581f190929b16861c7 to your computer and use it in GitHub Desktop. 
    Recent activity spec for the user profile page
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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