[refs #90] fixed pull tests
This commit is contained in:
parent
bf7bc8787a
commit
5bc59ad365
|
@ -11,16 +11,16 @@ shared_context "pull request controller" do
|
||||||
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.path})
|
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.path})
|
||||||
|
|
||||||
@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.base_project
|
@pull.issue.user, @pull.issue.project = @project.owner, @pull.to_project
|
||||||
@pull.base_ref = 'master'
|
@pull.to_ref = 'master'
|
||||||
@pull.head_project, @pull.head_ref = @project, 'non_conflicts'
|
@pull.from_project, @pull.from_ref = @project, 'non_conflicts'
|
||||||
@pull.save
|
@pull.save
|
||||||
|
|
||||||
@create_params = {
|
@create_params = {
|
||||||
:pull_request => {:issue_attributes => {:title => 'create', :body => 'creating'},
|
:pull_request => {:issue_attributes => {:title => 'create', :body => 'creating'},
|
||||||
:base_ref => 'non_conflicts',
|
:to_ref => 'non_conflicts',
|
||||||
:head_ref => 'master'},
|
:from_ref => 'master'},
|
||||||
:base_project => @project.name_with_owner,
|
:to_project => @project.name_with_owner,
|
||||||
:owner_name => @project.owner.uname,
|
:owner_name => @project.owner.uname,
|
||||||
:project_name => @project.name }
|
:project_name => @project.name }
|
||||||
@update_params = @create_params.merge(
|
@update_params = @create_params.merge(
|
||||||
|
@ -66,12 +66,12 @@ shared_examples_for 'pull request user with project reader rights' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not create same pull" do
|
it "should not create same pull" do
|
||||||
post :create, @create_params.merge({:pull_request => {:issue_attributes => {:title => 'same', :body => 'creating'}, :head_ref => 'non_conflicts', :base_ref => 'master'}, :base_project_id => @project.id})
|
post :create, @create_params.merge({:pull_request => {:issue_attributes => {:title => 'same', :body => 'creating'}, :from_ref => 'non_conflicts', :to_ref => 'master'}, :to_project_id => @project.id})
|
||||||
PullRequest.joins(:issue).where(:issues => {:title => 'same', :body => 'creating'}).count.should == 0
|
PullRequest.joins(:issue).where(:issues => {:title => 'same', :body => 'creating'}).count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not create already up-to-date pull" do
|
it "should not create already up-to-date pull" do
|
||||||
post :create, @create_params.merge({:pull_request => {:issue_attributes => {:title => 'already', :body => 'creating'}, :base_ref => 'master', :head_ref => 'master'}, :base_project_id => @project.id})
|
post :create, @create_params.merge({:pull_request => {:issue_attributes => {:title => 'already', :body => 'creating'}, :to_ref => 'master', :from_ref => 'master'}, :to_project_id => @project.id})
|
||||||
PullRequest.joins(:issue).where(:issues => {:title => 'already', :body => 'creating'}).count.should == 0
|
PullRequest.joins(:issue).where(:issues => {:title => 'already', :body => 'creating'}).count.should == 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -79,12 +79,12 @@ end
|
||||||
shared_examples_for 'user with pull request update rights' do
|
shared_examples_for 'user with pull request update rights' do
|
||||||
it 'should be able to perform update action' do
|
it 'should be able to perform update action' do
|
||||||
put :update, @update_params
|
put :update, @update_params
|
||||||
response.should redirect_to(project_pull_request_path(@pull.base_project, @pull))
|
response.should redirect_to(project_pull_request_path(@pull.to_project, @pull))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to perform merge action' do
|
it 'should be able to perform merge action' do
|
||||||
put :merge, @update_params
|
put :merge, @update_params
|
||||||
response.should redirect_to(project_pull_request_path(@pull.base_project, @pull))
|
response.should redirect_to(project_pull_request_path(@pull.to_project, @pull))
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:pull) { @project.pull_requests.find(@pull) }
|
let(:pull) { @project.pull_requests.find(@pull) }
|
||||||
|
|
|
@ -24,15 +24,15 @@ describe PullRequest do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_data_for_pull
|
set_data_for_pull
|
||||||
@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 = @user, @pull.base_project
|
@pull.issue.user, @pull.issue.project = @user, @pull.to_project
|
||||||
@pull.base_ref = 'master'
|
@pull.to_ref = 'master'
|
||||||
@pull.head_project, @pull.head_ref = @project, 'non_conflicts'
|
@pull.from_project, @pull.from_ref = @project, 'non_conflicts'
|
||||||
@pull.save
|
@pull.save
|
||||||
|
|
||||||
@other_pull = @project.pull_requests.new(:issue_attributes => {:title => 'test_other', :body => 'testing_other'})
|
@other_pull = @project.pull_requests.new(:issue_attributes => {:title => 'test_other', :body => 'testing_other'})
|
||||||
@other_pull.issue.user, @other_pull.issue.project = @user, @other_pull.base_project
|
@other_pull.issue.user, @other_pull.issue.project = @user, @other_pull.to_project
|
||||||
@other_pull.base_ref = 'master'
|
@other_pull.to_ref = 'master'
|
||||||
@other_pull.head_project, @other_pull.head_ref = @other_project, 'non_conflicts'
|
@other_pull.from_project, @other_pull.from_ref = @other_project, 'non_conflicts'
|
||||||
@other_pull.save
|
@other_pull.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,13 +42,13 @@ describe PullRequest do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'master should not merge with conflicts branch' do
|
it 'master should not merge with conflicts branch' do
|
||||||
@pull.head_ref = 'conflicts'
|
@pull.from_ref = 'conflicts'
|
||||||
@pull.check
|
@pull.check
|
||||||
@pull.status.should == 'blocked'
|
@pull.status.should == 'blocked'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should already merged when already up-to-date branches' do
|
it 'should already merged when already up-to-date branches' do
|
||||||
@pull.head_ref = 'master'
|
@pull.from_ref = 'master'
|
||||||
@pull.check
|
@pull.check
|
||||||
@pull.status.should == 'merged'
|
@pull.status.should == 'merged'
|
||||||
end
|
end
|
||||||
|
@ -60,13 +60,13 @@ describe PullRequest do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'master should not merge with conflicts branch' do
|
it 'master should not merge with conflicts branch' do
|
||||||
@other_pull.head_ref = 'conflicts'
|
@other_pull.from_ref = 'conflicts'
|
||||||
@other_pull.check
|
@other_pull.check
|
||||||
@other_pull.status.should == 'blocked'
|
@other_pull.status.should == 'blocked'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should already merged when already up-to-date branches' do
|
it 'should already merged when already up-to-date branches' do
|
||||||
@other_pull.head_ref = 'master'
|
@other_pull.from_ref = 'master'
|
||||||
@other_pull.check
|
@other_pull.check
|
||||||
@other_pull.status.should == 'merged'
|
@other_pull.status.should == 'merged'
|
||||||
end
|
end
|
||||||
|
@ -74,27 +74,27 @@ describe PullRequest do
|
||||||
|
|
||||||
it "should not create same pull" do
|
it "should not create same pull" do
|
||||||
@same_pull = @project.pull_requests.new(:issue_attributes => {:title => 'same', :body => 'testing'})
|
@same_pull = @project.pull_requests.new(:issue_attributes => {:title => 'same', :body => 'testing'})
|
||||||
@same_pull.issue.user, @same_pull.issue.project = @user, @same_pull.base_project
|
@same_pull.issue.user, @same_pull.issue.project = @user, @same_pull.to_project
|
||||||
@same_pull.base_ref = 'master'
|
@same_pull.to_ref = 'master'
|
||||||
@same_pull.head_project, @same_pull.head_ref = @project, 'non_conflicts'
|
@same_pull.from_project, @same_pull.from_ref = @project, 'non_conflicts'
|
||||||
@same_pull.save
|
@same_pull.save
|
||||||
@project.pull_requests.joins(:issue).where(:issues => {:title => @same_pull.title}).count.should == 0
|
@project.pull_requests.joins(:issue).where(:issues => {:title => @same_pull.title}).count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not create pull with wrong base ref" do
|
it "should not create pull with wrong base ref" do
|
||||||
@wrong_pull = @project.pull_requests.new(:issue_attributes => {:title => 'wrong base', :body => 'testing'})
|
@wrong_pull = @project.pull_requests.new(:issue_attributes => {:title => 'wrong base', :body => 'testing'})
|
||||||
@wrong_pull.issue.user, @wrong_pull.issue.project = @user, @wrong_pull.base_project
|
@wrong_pull.issue.user, @wrong_pull.issue.project = @user, @wrong_pull.to_project
|
||||||
@wrong_pull.base_ref = 'wrong'
|
@wrong_pull.to_ref = 'wrong'
|
||||||
@wrong_pull.head_project, @wrong_pull.head_ref = @project, 'non_conflicts'
|
@wrong_pull.from_project, @wrong_pull.from_ref = @project, 'non_conflicts'
|
||||||
@wrong_pull.save
|
@wrong_pull.save
|
||||||
@project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0
|
@project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not create pull with wrong head ref" do
|
it "should not create pull with wrong head ref" do
|
||||||
@wrong_pull = @project.pull_requests.new(:issue_attributes => {:title => 'wrong head', :body => 'testing'})
|
@wrong_pull = @project.pull_requests.new(:issue_attributes => {:title => 'wrong head', :body => 'testing'})
|
||||||
@wrong_pull.issue.user, @wrong_pull.issue.project = @user, @wrong_pull.base_project
|
@wrong_pull.issue.user, @wrong_pull.issue.project = @user, @wrong_pull.to_project
|
||||||
@wrong_pull.base_ref = 'master'
|
@wrong_pull.to_ref = 'master'
|
||||||
@wrong_pull.head_project, @wrong_pull.head_ref = @project, 'wrong'
|
@wrong_pull.from_project, @wrong_pull.from_ref = @project, 'wrong'
|
||||||
@wrong_pull.save
|
@wrong_pull.save
|
||||||
@project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0
|
@project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0
|
||||||
end
|
end
|
||||||
|
@ -105,8 +105,8 @@ describe PullRequest do
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should belong_to(:issue) }
|
it { should belong_to(:issue) }
|
||||||
it { should belong_to(:base_project) }
|
it { should belong_to(:to_project) }
|
||||||
it { should belong_to(:head_project) }
|
it { should belong_to(:from_project) }
|
||||||
|
|
||||||
after do
|
after do
|
||||||
FileUtils.rm_rf(APP_CONFIG['root_path'])
|
FileUtils.rm_rf(APP_CONFIG['root_path'])
|
||||||
|
|
Loading…
Reference in New Issue