[#369] fix specs

This commit is contained in:
Alexander Machehin 2015-02-02 23:21:43 +05:00
parent 79dbe762e5
commit bfeb3c218b
4 changed files with 16 additions and 32 deletions

View File

@ -13,7 +13,7 @@ shared_context "comments controller" do
set_session_for(@user) set_session_for(@user)
@path = { name_with_owner: @project.name_with_owner, issue_id: @issue.serial_id } @path = { name_with_owner: @project.name_with_owner, issue_id: @issue.serial_id, format: :json }
@return_path = project_issue_path(@project, @issue) @return_path = project_issue_path(@project, @issue)
@create_params = { comment: { body: 'I am a comment!' }}.merge(@path) @create_params = { comment: { body: 'I am a comment!' }}.merge(@path)
@update_params = { comment: { body: 'updated' }}.merge(@path) @update_params = { comment: { body: 'updated' }}.merge(@path)

View File

@ -26,7 +26,7 @@ shared_context "issues controller" do
} }
} }
@update_params = { name_with_owner: @project.name_with_owner, issue: { title: "issue2" }} @update_params = { name_with_owner: @project.name_with_owner, issue: { title: "issue2" }, format: :json }
@pull = @project.pull_requests.new issue_attributes: { title: 'test', body: 'testing' } @pull = @project.pull_requests.new issue_attributes: { title: 'test', body: 'testing' }
@pull.issue.user, @pull.issue.project = @project.owner, @pull.to_project @pull.issue.user, @pull.issue.project = @project.owner, @pull.to_project
@ -106,7 +106,7 @@ end
shared_examples_for 'user without issue update rights' do shared_examples_for 'user without issue update rights' do
it 'should not be able to perform update action' do it 'should not be able to perform update action' do
put :update, {id: @issue.serial_id}.merge(@update_params) put :update, {id: @issue.serial_id}.merge(@update_params)
response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path) response.should redirect_to(forbidden_path)
end end
it 'should not update issue title' do it 'should not update issue title' do
@ -291,7 +291,17 @@ describe Projects::IssuesController do
lambda{ post :create, @create_params }.should_not change{ Issue.count } lambda{ post :create, @create_params }.should_not change{ Issue.count }
end end
it_should_behave_like 'user without issue update rights' #it_should_behave_like 'user without issue update rights'
it 'should not be able to perform update action' do
put :update, {id: @issue.serial_id}.merge(@update_params)
response.status.should == 401
end
it 'should not update issue title' do
put :update, {id: @issue.serial_id}.merge(@update_params)
@issue.reload.title.should_not == 'issue2'
end
# it_should_behave_like 'user without issue destroy rights' # it_should_behave_like 'user without issue destroy rights'
end end
end end

View File

@ -35,11 +35,6 @@ shared_context "pull request controller" do
end end
shared_examples_for 'pull request user with project guest rights' do shared_examples_for 'pull request user with project guest rights' do
it 'should be able to perform index action' do
get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index)
end
it 'should be able to perform show action when pull request has been created' do it 'should be able to perform show action when pull request has been created' do
@pull.check @pull.check
get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id
@ -48,12 +43,6 @@ shared_examples_for 'pull request user with project guest rights' do
end end
shared_examples_for 'pull request user with project reader rights' do shared_examples_for 'pull request user with project reader rights' do
it 'should be able to perform index action on hidden project' do
@project.update_attributes(visibility: 'hidden')
get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index)
end
it 'should be able to perform create action' do it 'should be able to perform create action' do
post :create, @create_params post :create, @create_params
response.should redirect_to(project_pull_request_path(@project, @project.pull_requests.last)) response.should redirect_to(project_pull_request_path(@project, @project.pull_requests.last))
@ -163,10 +152,6 @@ end
shared_examples_for 'pull request when project with issues turned off' do shared_examples_for 'pull request when project with issues turned off' do
before { @project.update_attributes(has_issues: false) } before { @project.update_attributes(has_issues: false) }
it 'should be able to perform index action' do
get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index)
end
it 'should be able to perform show action when pull request has been created' do it 'should be able to perform show action when pull request has been created' do
@pull.check @pull.check
@ -268,22 +253,11 @@ describe Projects::PullRequestsController do
it_should_behave_like 'pull request when project with issues turned off' it_should_behave_like 'pull request when project with issues turned off'
else else
it 'should not be able to perform index action' do
get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(new_user_session_path)
end
it 'should not be able to perform show action' do it 'should not be able to perform show action' do
@pull.check @pull.check
get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
it 'should not be able to perform index action on hidden project' do
@project.update_attributes(visibility: 'hidden')
get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(new_user_session_path)
end
end end
it 'should not be able to perform create action' do it 'should not be able to perform create action' do

View File

@ -38,7 +38,7 @@ end
shared_examples_for 'user with create comment ability' do shared_examples_for 'user with create comment ability' do
it 'should be able to perform create action' do it 'should be able to perform create action' do
post :create, @create_params post :create, @create_params
response.should redirect_to(@return_path+"#comment#{Comment.last.id}") response.should be_success #redirect_to(@return_path+"#comment#{Comment.last.id}")
end end
it 'should create comment in the database' do it 'should create comment in the database' do
@ -81,7 +81,7 @@ end
shared_examples_for 'user with destroy comment ability' do shared_examples_for 'user with destroy comment ability' do
it 'should be able to perform destroy action' do it 'should be able to perform destroy action' do
delete :destroy, {id: @comment.id}.merge(@path) delete :destroy, {id: @comment.id}.merge(@path)
response.should redirect_to(@return_path) response.should be_success #redirect_to(@return_path)
end end
it 'should delete comment from database' do it 'should delete comment from database' do