2011-03-10 11:35:46 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-02-19 01:12:08 +00:00
|
|
|
describe Users::ProfileController, type: :controller do
|
2011-12-15 17:08:29 +00:00
|
|
|
before(:each) do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2011-12-15 17:08:29 +00:00
|
|
|
|
2012-03-29 21:34:22 +01:00
|
|
|
@simple_user = FactoryGirl.create(:user)
|
|
|
|
@other_user = FactoryGirl.create(:user)
|
|
|
|
@admin = FactoryGirl.create(:admin)
|
2011-12-15 17:08:29 +00:00
|
|
|
%w[user1 user2 user3].each do |uname|
|
2014-01-21 04:51:49 +00:00
|
|
|
FactoryGirl.create(:user, uname: uname, email: "#{ uname }@nonexistanceserver.com")
|
2011-12-15 17:08:29 +00:00
|
|
|
end
|
2014-01-21 04:51:49 +00:00
|
|
|
@update_params = {email: 'new_email@test.com'}
|
2011-12-15 17:08:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'for guest' do
|
2014-01-21 04:51:49 +00:00
|
|
|
it 'should be able to view profile', anonymous_access: true do
|
|
|
|
get :show, uname: @simple_user.uname
|
2015-04-06 23:54:16 +01:00
|
|
|
expect(response).to be_success
|
2012-10-02 18:22:24 +01:00
|
|
|
end
|
2014-01-21 04:51:49 +00:00
|
|
|
it 'should not be able to perform show action', anonymous_access: false do
|
|
|
|
get :show, uname: @simple_user.uname
|
2015-04-06 23:54:16 +01:00
|
|
|
expect(response).to redirect_to(new_user_session_path)
|
2012-03-21 20:05:27 +00:00
|
|
|
end
|
2011-12-15 17:08:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'for simple user' do
|
|
|
|
before(:each) do
|
|
|
|
set_session_for(@simple_user)
|
|
|
|
end
|
2011-03-10 11:35:46 +00:00
|
|
|
|
2012-03-21 20:05:27 +00:00
|
|
|
it 'should be able to view profile' do
|
2014-01-21 04:51:49 +00:00
|
|
|
get :show, uname: @other_user.uname
|
2015-04-06 23:54:16 +01:00
|
|
|
expect(response).to be_success
|
2012-03-21 20:05:27 +00:00
|
|
|
end
|
|
|
|
|
2011-12-15 17:08:29 +00:00
|
|
|
end
|
2011-03-10 11:35:46 +00:00
|
|
|
end
|