public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Search Repo:
insoshi / spec / helpers / activities_helper_spec.rb
100644 57 lines (49 sloc) 2.037 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require File.dirname(__FILE__) + '/../spec_helper'
include ActivitiesHelper
include SharedHelper
include PeopleHelper
describe ActivitiesHelper do
 
  before(:each) do
    @current_person = login_as(:aaron)
    # It sucks that RSpec makes me do this.
    self.stub!(:logged_in?).and_return(true)
    self.stub!(:current_person).and_return(people(:aaron))
  end
  
  it "should have the right message for a wall comment" do
    # Quentin comments an Aaron's wall
    person = @current_person
    commenter = people(:quentin)
    comment = person.comments.create(:body => "The body",
                                     :commenter => commenter)
    activity = Activity.find_by_item_id(comment)
    # The message works even if logged in as Kelly.
    login_as(:kelly)
    feed_message(activity).should =~ /#{commenter.name}/
    feed_message(activity).should =~ /#{person.name}'s wall/
    # The message works even if logged in as the commenter
    login_as(commenter)
    feed_message(activity).should =~ /#{commenter.name}/
    feed_message(activity).should =~ /#{person.name}'s wall/
  end
 
  it "should have the right message for an own-comment" do
    person = @current_person
    commenter = person
    comment = person.comments.create(:body => "The body",
                                     :commenter => commenter)
    activity = Activity.find_by_item_id(comment)
    login_as(:kelly)
    feed_message(activity).should =~ /#{commenter.name}/
    feed_message(activity).should =~ /#{commenter.name}'s wall/
  end
  
  
  it "should have the right message for a blog comment" do
    post = posts(:blog_post)
    comment = post.comments.create(:body => "The body",
                                   :commenter => @current_person)
    activity = Activity.find_by_item_id(comment)
    feed_message(activity).should =~ /blog post/
  end
  
  it "should have the right message for a photo" do
    activity = Activity.new(:item => mock_photo, :person => @current_person)
    feed_message(activity).should =~ /profile picture/
  end
 
end