Commit 9b39be250cf47cd3e13df4effbc9364d14108303

Authored by Fellipe Souto
Committed by Rafael Manzo
1 parent f1711396

Unit test for RepositoriesController create method

Signed-off By: Rafael Reggiani Manzo <rr.manzo@gmail.com>
spec/controllers/repositories_controller_spec.rb
... ... @@ -25,6 +25,7 @@ describe RepositoriesController do
25 25 get :new, project_id: project.id.to_s
26 26 end
27 27  
  28 + it { should redirect_to(projects_url) }
28 29 it { should respond_with(:redirect) }
29 30 end
30 31 end
... ... @@ -54,18 +55,26 @@ describe RepositoriesController do
54 55 it { should respond_with(:redirect) }
55 56 end
56 57  
57   - pending "It still fails :(" do
58 58 context 'with an invalid field' do
59 59 before :each do
60 60 Repository.expects(:new).at_least_once.with(@subject_params).returns(@subject)
61 61 Repository.any_instance.expects(:save).returns(false)
  62 + Repository.any_instance.expects(:persisted?).at_least_once.returns(false)
62 63  
63 64 post :create, project_id: project.id.to_s, repository: @subject_params
64 65 end
65 66  
66 67 it { should render_template(:new) }
67 68 end
  69 + end
  70 +
  71 + context "when the current user doesn't owns the project " do
  72 + before :each do
  73 + post :create, project_id: project.id, repository: @subject_params
68 74 end
  75 +
  76 + it { should redirect_to(projects_url) }
  77 + it { should respond_with(:redirect) }
69 78 end
70 79 end
71 80  
... ...