Permalink
Browse files

added specs for activity history, cleaned whitespace

  • Loading branch information...
1 parent 1daf8a5 commit fd98c8b6e16e45b1e50f794514b27c5f2c4a1e1b @bdong281 bdong281 committed Apr 26, 2012
Showing with 44 additions and 14 deletions.
  1. +14 −14 spec/controllers/messages_controller_spec.rb
  2. +30 −0 spec/controllers/users_controller_spec.rb
@@ -39,10 +39,10 @@
describe '#show' do
it 'should show a specific message and update read status' do
- fake_message = FactoryGirl.create(:message,
+ fake_message = FactoryGirl.create(:message,
:id => '1234',
- :to_user => @user.id,
- :from_user => 'admin',
+ :to_user => @user.id,
+ :from_user => 'admin',
:subject => 'asdf',
:status => 'unread',
:content => 'aeou')
@@ -52,10 +52,10 @@
fake_message.status.should = 'read'
end
it 'should not update read status for authored messages' do
- fake_message = FactoryGirl.create(:message,
+ fake_message = FactoryGirl.create(:message,
:id => '1234',
- :to_user => 'admin',
- :from_user => @user.id,
+ :to_user => 'admin',
+ :from_user => @user.id,
:subject => 'asdf',
:status => 'unread',
:content => 'aeou')
@@ -65,17 +65,17 @@
fake_message.status.should_not = 'read'
end
it 'should not be able to show messages not directed to or written by the user' do
- fake_message = FactoryGirl.create(:message,
+ fake_message = FactoryGirl.create(:message,
:id => '1234',
- :to_user => @user.id + 2,
- :from_user => 'admin',
+ :to_user => @user.id + 2,
+ :from_user => 'admin',
:subject => 'asdf',
:status => 'unread',
:content => 'aeou')
- fake_message2 = FactoryGirl.create(:message,
+ fake_message2 = FactoryGirl.create(:message,
:id => '1235',
- :to_user => 'admin',
- :from_user => @user.id + 3,
+ :to_user => 'admin',
+ :from_user => @user.id + 3,
:subject => 'asdf',
:status => 'unread',
:content => 'aeou')
@@ -84,7 +84,7 @@
response.should redirect_to(message_path)
flash[:error].should == 'You are not allowed to view this message'
fake_message.status.should_not = 'read'
-
+
Video.should_receive(:find_by_id).with('1235').and_return(fake_message2)
get :show, {:id => '1235'}
response.should redirect_to(message_path)
@@ -140,5 +140,5 @@
end
end
-
+
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe UsersController do
+
+ before(:each) do
+ @user = FactoryGirl.create(:user, :id => '1')
+ sign_in @user
+ end
+
+ describe '#show' do
+
+ it 'should display the profile for the correct user' do
+ get :show, {:id => @user.id}
+ response.should render_template('users/show')
+ end
+
+ it 'should display all comments and messages by the user' do
+ fake_comment = FactoryGirl.create(:comment, :user_id => @user.id,
+ :content => 'Some comment here')
+ fake_message = FactoryGirl.create(:message, :to_user => 'admin',
+ :from_user => @user.id,
+ :content => 'Some message here')
+ get :show, {:id => @user.id}
+ response.should have_selector('.comments', :text => 'Some comment here')
+ response.should have_selector('.messages', :text => 'Some message here')
+ end
+
+ end
+
+end

0 comments on commit fd98c8b

Please sign in to comment.