diff options
author | Izaak Alpert <ialpert@blackberry.com> | 2013-06-04 00:20:50 +0400 |
---|---|---|
committer | Izaak Alpert <ialpert@blackberry.com> | 2013-07-18 06:42:51 +0400 |
commit | 489fa5d72631505873b8c33f3a2bbd5919330a92 (patch) | |
tree | 077d5b267d1875c905d566dfe972f65507ee826b /spec | |
parent | 3d7194f0112da12e8732df9ffe8b34fe7d0a9f6b (diff) |
MR on Fork multiple fixes
-Disable observers post test run
-Allow db:seed_fu RAILS_ENV=test to be run more than once without error
-fix diffs_in_between, was passing in the default_options for grit, but grit in this case doesn't take options, fixed the test to actually fail if the incorrect diffs are returned
-make notes/commits render against proper project
-MR discussion file links should reference note's project
-Added tests for commit links on edit merge request
-fixes edit issues (canceling an edited mr, updating an edited mr)
-updates tests with checks for source code updates
-still forked_merge_requests.feature (project_forked_merge_requests) test not passing (commented out -- "stable" not being set)
MR API: error on bad target_project
-If the target project id is specified and it is not the same as the project the request is being made on (the source), and the it isn't a fork of that project, error out, otherwise use it as the target
-Fixes some busted (but hidden) test cases
Conflicts:
app/views/merge_requests/show/_diffs.html.haml
spec/features/notes_on_merge_requests_spec.rb
Change-Id: I20e595c156d0e8a63048baaead7be6330c738a05
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/notes_on_merge_requests_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/satellite/merge_action_spec.rb | 17 | ||||
-rw-r--r-- | spec/observers/merge_request_observer_spec.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 15 |
4 files changed, 30 insertions, 7 deletions
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index 34e07e72056..4fd7af89d21 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -184,6 +184,9 @@ describe "On a merge request diff", js: true, focus: true do end describe "with muliple note forms" do + let!(:project) { create(:source_project_with_code) } + let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } + before do find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click find('a[data-line-code="342e16cbbd482ac2047dc679b2749d248cc1428f_18_17"]').click diff --git a/spec/lib/gitlab/satellite/merge_action_spec.rb b/spec/lib/gitlab/satellite/merge_action_spec.rb index 36e6b3c7973..d0b59d379c8 100644 --- a/spec/lib/gitlab/satellite/merge_action_spec.rb +++ b/spec/lib/gitlab/satellite/merge_action_spec.rb @@ -76,6 +76,13 @@ describe 'Gitlab::Satellite::MergeAction' do describe '#diffs_between_satellite tested against diff_in_satellite' do + + def is_a_matching_diff(diff, diffs) + diff_count = diff.scan('diff --git').size + diff_count.should >= 1 + diffs.size.should == diff_count + diffs.each {|a_diff| (diff.include? a_diff.diff).should be_true} + end context 'on fork' do it 'should get proper diffs' do merge_request_fork.target_branch = @close_commit1[0] @@ -84,24 +91,24 @@ describe 'Gitlab::Satellite::MergeAction' do merge_request_fork.target_branch = @close_commit1[0] merge_request_fork.source_branch = @master[0] - diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request_fork).diffs_between_satellite + diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request_fork).diff_in_satellite - diffs.each {|a_diff| (diff.include? a_diff.diff).should be_true} + is_a_matching_diff(diff,diffs) end end context 'between branches' do it 'should get proper diffs' do merge_request.target_branch = @close_commit1[0] - merge_request.source_branch = @wiki_branch[0] + merge_request.source_branch = @master[0] diffs = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite merge_request.target_branch = @close_commit1[0] merge_request.source_branch = @master[0] - diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite + diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diff_in_satellite - diffs.each {|a_diff| (diff.include? a_diff.diff).should be_true} + is_a_matching_diff(diff,diffs) end end end diff --git a/spec/observers/merge_request_observer_spec.rb b/spec/observers/merge_request_observer_spec.rb index 249700f543d..a6efd96e450 100644 --- a/spec/observers/merge_request_observer_spec.rb +++ b/spec/observers/merge_request_observer_spec.rb @@ -107,7 +107,7 @@ describe MergeRequestObserver do end after do - TestEnv.enable_observers + TestEnv.disable_observers end it_should_be_valid_event diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 7e5bf29788d..7b893c43379 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -79,6 +79,7 @@ describe API::API do let!(:user2) {create(:user)} let!(:forked_project_link) { build(:forked_project_link) } let!(:fork_project) { create(:source_project_with_code, forked_project_link: forked_project_link, namespace: user2.namespace, creator_id: user2.id) } + let!(:unrelated_project) { create(:target_project_with_code, namespace: user2.namespace, creator_id: user2.id) } before :each do |each| fork_project.team << [user2, :reporters] @@ -124,9 +125,21 @@ describe API::API do it "should return 400 when target_branch is specified and not a forked project" do post api("/projects/#{project.id}/merge_requests", user), - target_branch: 'master', source_branch: 'stable', author: user, target_project: fork_project.id + title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user, target_project_id: fork_project.id response.status.should == 400 end + + it "should return 400 when target_branch is specified and for a different fork" do + post api("/projects/#{fork_project.id}/merge_requests", user2), + title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: unrelated_project.id + response.status.should == 400 + end + + it "should return 201 when target_branch is specified and for the same project" do + post api("/projects/#{fork_project.id}/merge_requests", user2), + title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: fork_project.id + response.status.should == 201 + end end end |