Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed indentation

  • Loading branch information...
commit 02c1a9ea472c33e1feba236eeb68c29010e26c73 1 parent 1f1f79f
@hcarreras hcarreras authored
Showing with 49 additions and 35 deletions.
  1. +49 −35 spec/controllers/user_controller_spec.rb
View
84 spec/controllers/user_controller_spec.rb
@@ -1,39 +1,53 @@
require 'spec_helper'
describe UsersController do
- let(:bob){Fabricate(:user)}
- let(:mozart){Fabricate(:user)}
-
- describe('#index') do
- context "When user is no moderator" do
- it "try to get index" do
- get :index
- response.should redirect_to(root_path)
- end
- end
-
- context "When user is moderator" do
- before { sign_in Fabricate(:user, moderator: true) }
- it "gets index with authorization" do
- get :index
- response.should be_success
- end
- end
- end
-
- describe 'Following actions' do
- before { sign_in bob }
- it('#follow') do
- post :follow, user_id: bob, :user => {:followee => mozart.id}
- expect(flash[:notice]).to eq("You're following #{mozart.username} now")
- end
- it('#following?') do
- get :following, user_id: bob
- response.should be_success
- end
- it ('#followers') do
- get :followers, user_id: bob
- response.should be_success
- end
- end
+ let(:bob){Fabricate(:user)}
+ let(:mozart){Fabricate(:user)}
+
+ describe('#index') do
+ context "When user is no moderator" do
+ it "try to get index" do
+ get :index
+ response.should redirect_to(root_path)
+ end
+ end
+
+ context "When user is moderator" do
+ before { sign_in Fabricate(:user, moderator: true) }
+ it "gets index with authorization" do
+ get :index
+ response.should be_success
+ end
+ end
+ end
+
+ describe 'Following actions' do
+ before { sign_in bob }
+ it('Try to follow himself') do
+ post :follow, user_id: bob, :user => {:followee => bob.id}
+ expect(flash[:notice]).to eq("You can't follow yourself silly!")
+ end
+
+ it('#follow just once') do
+ post :follow, user_id: bob, :user => {:followee => mozart.id}
+ expect(flash[:notice]).to eq("You're following #{mozart.username} now")
+ post :follow, user_id: bob, :user => {:followee => mozart.id}
+ expect(flash[:notice]).to eq("You're already following #{mozart.username}")
+ end
+
+ it('#following?') do
+ get :following, user_id: bob
+ response.should be_success
+ end
+
+ it ('#followers') do
+ get :followers, user_id: bob
+ response.should be_success
+ end
+
+ it ('#unfollow') do
+ post :unfollow, user_id: bob, :user => {:followee => mozart.id}
+ expect(flash[:notice]).to eq("You're no longer following #{mozart.username}")
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.