Commit 24281da8907651895d65a40d5016eacbdc8eaa60

Authored by Beatriz Rezener
1 parent 6b6c23b9

Test RepositoryController: Context when there's no user logged in

Showing 1 changed file with 23 additions and 13 deletions   Show diff stats
spec/controllers/repositories_controller_spec.rb
... ... @@ -4,29 +4,39 @@ describe RepositoriesController, :type => :controller do
4 4 let(:project) { FactoryGirl.build(:project) }
5 5  
6 6 describe 'new' do
7   - before :each do
8   - sign_in FactoryGirl.create(:user) #TODO create a context when there's no user logged in
9   - end
10   -
11   - context 'when the current user owns the project' do
  7 + context 'with an User logged in' do
12 8 before :each do
13   - Repository.expects(:repository_types).returns([])
14   - subject.expects(:project_owner?).returns true
  9 + sign_in FactoryGirl.create(:user)
  10 + end
15 11  
16   - get :new, project_id: project.id.to_s
  12 + context 'when the current user owns the project' do
  13 + before :each do
  14 + Repository.expects(:repository_types).returns([])
  15 + subject.expects(:project_owner?).returns true
  16 +
  17 + get :new, project_id: project.id.to_s
  18 + end
  19 +
  20 + it { is_expected.to respond_with(:success) }
  21 + it { is_expected.to render_template(:new) }
17 22 end
18 23  
19   - it { is_expected.to respond_with(:success) }
20   - it { is_expected.to render_template(:new) }
  24 + context "when the current user doesn't owns the project" do
  25 + before :each do
  26 + get :new, project_id: project.id.to_s
  27 + end
  28 +
  29 + it { is_expected.to redirect_to(projects_url) }
  30 + it { is_expected.to respond_with(:redirect) }
  31 + end
21 32 end
22 33  
23   - context "when the current user doesn't owns the project" do
  34 + context 'with no user logged in' do
24 35 before :each do
25 36 get :new, project_id: project.id.to_s
26 37 end
27 38  
28   - it { is_expected.to redirect_to(projects_url) }
29   - it { is_expected.to respond_with(:redirect) }
  39 + it { is_expected.to redirect_to new_user_session_path }
30 40 end
31 41 end
32 42  
... ...