[refs #90] fixed pull tests

This commit is contained in:
Alexander Machehin 2012-10-03 18:18:02 +06:00
parent bf7bc8787a
commit 5bc59ad365
2 changed files with 31 additions and 31 deletions

View File

@ -11,16 +11,16 @@ shared_context "pull request controller" do
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.path})
@pull = @project.pull_requests.new :issue_attributes => {:title => 'test', :body => 'testing'}
@pull.issue.user, @pull.issue.project = @project.owner, @pull.base_project
@pull.base_ref = 'master'
@pull.head_project, @pull.head_ref = @project, 'non_conflicts'
@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
@create_params = {
:pull_request => {:issue_attributes => {:title => 'create', :body => 'creating'},
:base_ref => 'non_conflicts',
:head_ref => 'master'},
:base_project => @project.name_with_owner,
:to_ref => 'non_conflicts',
:from_ref => 'master'},
:to_project => @project.name_with_owner,
:owner_name => @project.owner.uname,
:project_name => @project.name }
@update_params = @create_params.merge(
@ -66,12 +66,12 @@ shared_examples_for 'pull request user with project reader rights' do
end
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
end
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
end
end
@ -79,12 +79,12 @@ end
shared_examples_for 'user with pull request update rights' do
it 'should be able to perform update action' do
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
it 'should be able to perform merge action' do
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
let(:pull) { @project.pull_requests.find(@pull) }

View File

@ -24,15 +24,15 @@ describe PullRequest do
@user = FactoryGirl.create(:user)
set_data_for_pull
@pull = @project.pull_requests.new(:issue_attributes => {:title => 'test', :body => 'testing'})
@pull.issue.user, @pull.issue.project = @user, @pull.base_project
@pull.base_ref = 'master'
@pull.head_project, @pull.head_ref = @project, 'non_conflicts'
@pull.issue.user, @pull.issue.project = @user, @pull.to_project
@pull.to_ref = 'master'
@pull.from_project, @pull.from_ref = @project, 'non_conflicts'
@pull.save
@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.base_ref = 'master'
@other_pull.head_project, @other_pull.head_ref = @other_project, 'non_conflicts'
@other_pull.issue.user, @other_pull.issue.project = @user, @other_pull.to_project
@other_pull.to_ref = 'master'
@other_pull.from_project, @other_pull.from_ref = @other_project, 'non_conflicts'
@other_pull.save
end
@ -42,13 +42,13 @@ describe PullRequest do
end
it 'master should not merge with conflicts branch' do
@pull.head_ref = 'conflicts'
@pull.from_ref = 'conflicts'
@pull.check
@pull.status.should == 'blocked'
end
it 'should already merged when already up-to-date branches' do
@pull.head_ref = 'master'
@pull.from_ref = 'master'
@pull.check
@pull.status.should == 'merged'
end
@ -60,13 +60,13 @@ describe PullRequest do
end
it 'master should not merge with conflicts branch' do
@other_pull.head_ref = 'conflicts'
@other_pull.from_ref = 'conflicts'
@other_pull.check
@other_pull.status.should == 'blocked'
end
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.status.should == 'merged'
end
@ -74,27 +74,27 @@ describe PullRequest do
it "should not create same pull" do
@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.base_ref = 'master'
@same_pull.head_project, @same_pull.head_ref = @project, 'non_conflicts'
@same_pull.issue.user, @same_pull.issue.project = @user, @same_pull.to_project
@same_pull.to_ref = 'master'
@same_pull.from_project, @same_pull.from_ref = @project, 'non_conflicts'
@same_pull.save
@project.pull_requests.joins(:issue).where(:issues => {:title => @same_pull.title}).count.should == 0
end
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.issue.user, @wrong_pull.issue.project = @user, @wrong_pull.base_project
@wrong_pull.base_ref = 'wrong'
@wrong_pull.head_project, @wrong_pull.head_ref = @project, 'non_conflicts'
@wrong_pull.issue.user, @wrong_pull.issue.project = @user, @wrong_pull.to_project
@wrong_pull.to_ref = 'wrong'
@wrong_pull.from_project, @wrong_pull.from_ref = @project, 'non_conflicts'
@wrong_pull.save
@project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0
end
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.issue.user, @wrong_pull.issue.project = @user, @wrong_pull.base_project
@wrong_pull.base_ref = 'master'
@wrong_pull.head_project, @wrong_pull.head_ref = @project, 'wrong'
@wrong_pull.issue.user, @wrong_pull.issue.project = @user, @wrong_pull.to_project
@wrong_pull.to_ref = 'master'
@wrong_pull.from_project, @wrong_pull.from_ref = @project, 'wrong'
@wrong_pull.save
@project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0
end
@ -105,8 +105,8 @@ describe PullRequest do
end
it { should belong_to(:issue) }
it { should belong_to(:base_project) }
it { should belong_to(:head_project) }
it { should belong_to(:to_project) }
it { should belong_to(:from_project) }
after do
FileUtils.rm_rf(APP_CONFIG['root_path'])