add some specs for redirecting from issues to pulls and vice versa

This commit is contained in:
Alexander Machehin 2013-07-22 21:19:25 +06:00
parent c33588f620
commit 5947030325
4 changed files with 58 additions and 3 deletions

View File

@ -7,8 +7,8 @@ describe Api::V1::IssuesController do
stub_redis
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@issue = FactoryGirl.create(:issue)
@project = @issue.project
@project = FactoryGirl.create(:project_with_commit)
@issue = FactoryGirl.create(:issue, :project => @project)
@membered_issue = FactoryGirl.create(:issue)
@membered_project = @membered_issue.project
@ -27,6 +27,12 @@ describe Api::V1::IssuesController do
@create_params = {:issue => {:title => 'title', :body => 'body'}, :project_id => @project.id, :format => :json}
@update_params = {:issue => {:title => 'new title'}, :project_id => @project.id, :id => @issue.serial_id, :format => :json}
@pull = @project.pull_requests.new :issue_attributes => {:title => 'test', :body => 'testing'}
@pull.issue.user, @pull.issue.project = @project.owner, @pull.to_project
@pull.to_ref = 'master'
@pull.from_project, @pull.from_ref = @project, 'non_conflicts'
@pull.save
end
context 'read and accessible abilities' do
@ -100,6 +106,16 @@ describe Api::V1::IssuesController do
response.status.should == 401
end
end
it 'should return 404' do
get :show, :project_id => @project.id, :id => (@issue.serial_id + 10), :format => :json
response.status.should == 404
end
it 'should redirect to pull request page' do
get :show, :project_id => @project.id, :id => @pull.serial_id, :format => :json
response.should redirect_to(api_v1_project_pull_request_path(@project.id, @pull.serial_id))
end
end
context 'create accessibility' do

View File

@ -38,6 +38,8 @@ describe Api::V1::PullRequestsController do
@update_params = {:pull_request => {:title => 'new title'},
:project_id => @project.id, :id => @pull.serial_id, :format => :json}
@issue = FactoryGirl.create(:issue, :project => @project)
end
context 'read and accessible abilities' do
@ -110,6 +112,16 @@ describe Api::V1::PullRequestsController do
response.should_not be_success
end
end
it 'should return 404' do
get :show, :project_id => @project.id, :id => (@pull.serial_id+10), :format => :json
response.status.should == 404
end
it 'should redirect to issue page' do
get :show, :project_id => @project.id, :id => @issue.serial_id, :format => :json
response.should redirect_to(api_v1_project_issue_path(@project.id, @issue.serial_id))
end
end
context 'for anonymous user' do

View File

@ -5,7 +5,7 @@ shared_context "issues controller" do
before do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@project = FactoryGirl.create(:project_with_commit)
@issue_user = FactoryGirl.create(:user)
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :assignee_id => @issue_user.id)
@ -34,6 +34,11 @@ shared_context "issues controller" do
}
}
@pull = @project.pull_requests.new :issue_attributes => {:title => 'test', :body => 'testing'}
@pull.issue.user, @pull.issue.project = @project.owner, @pull.to_project
@pull.to_ref = 'master'
@pull.from_project, @pull.from_ref = @project, 'non_conflicts'
@pull.save
end
end
@ -214,6 +219,16 @@ describe Projects::IssuesController do
# it 'should not create issue object into db' do
# lambda{ post :create, @create_params }.should change{ Issue.count }.by(0)
# end
it 'should return 404' do
get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => (@issue.serial_id+10)
response.status.should == 404
end
it 'should redirect to pull request page' do
get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => @pull.serial_id
response.should redirect_to(project_pull_request_path(@project, @pull))
end
end
context 'for project writer user' do

View File

@ -31,6 +31,8 @@ shared_context "pull request controller" do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@issue = FactoryGirl.create(:issue, :project => @project)
end
end
@ -207,6 +209,16 @@ describe Projects::PullRequestsController do
it_should_behave_like 'pull request user with project reader rights'
it_should_behave_like 'user without pull request update rights'
it_should_behave_like 'pull request when project with issues turned off'
it 'should return 404' do
get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => (@pull.serial_id+10)
response.status.should == 404
end
it 'should redirect to issue page' do
get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => @issue.serial_id
response.should redirect_to(project_issue_path(@project, @issue))
end
end
context 'for project writer user' do