end
if opened? || reopened?
- similar_mrs = self.project.merge_requests.where(source_branch: source_branch, target_branch: target_branch).opened
+ similar_mrs = self.target_project.merge_requests.where(source_branch: source_branch, target_branch: target_branch, source_project_id: source_project.id).opened
similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id
if similar_mrs.any?
- errors.add :base, "There is already an open merge request for this branches"
+ errors.add :base, "Cannot Create: This merge request already exists: #{similar_mrs.pluck(:title)}"
end
end
end
class MergeRequestObserver < ActivityObserver
observe :merge_request
- cattr_accessor :current_user
def after_create(merge_request)
event_author_id = merge_request.author_id
end
And 'I submit new merge request "Wiki Feature"' do
- fill_in "merge_request_title", :with => "Wiki Feature"
+ #this must come first, so that the target branch is set by the time the "select" for "notes_refactoring" is executed
select project.path_with_namespace, :from => "merge_request_target_project_id"
+ fill_in "merge_request_title", :with => "Wiki Feature"
select "master", :from => "merge_request_source_branch"
- select "stable", :from => "merge_request_target_branch"
- find(:select, "merge_request_target_branch", {}).find(:option, "stable", {}).value.should == "stable"
+ find(:select, "merge_request_target_project_id", {}).value.should == project.id.to_s
+ find(:select, "merge_request_source_project_id", {}).value.should == project.id.to_s
+
+ #using "notes_refactoring" because "Bug NS-04" uses master/stable, this will fail merge_request validation if the branches are the same
+ find(:select, "merge_request_target_branch", {}).find(:option, "notes_refactoring", {}).value.should == "notes_refactoring"
+ select "notes_refactoring", :from => "merge_request_target_branch"
+
click_button "Submit merge request"
end
let(:merge_request1) { create(:merge_request, author_id: user.id, source_project: project1, target_project: project2) }
let(:merge_request2) { create(:merge_request, author_id: user.id, source_project: project2, target_project: project1) }
let(:merge_request3) { create(:merge_request, author_id: user.id, source_project: project2, target_project: project2) }
- let(:merge_request4) { create(:merge_request, author_id: user2.id, source_project: project2, target_project: project2) }
+ let(:merge_request4) { create(:merge_request, author_id: user2.id, source_project: project2, target_project: project2, target_branch:"notes_refactoring") }
let(:issue1) { create(:issue, assignee_id: user.id, project: project1) }
let(:issue2) { create(:issue, assignee_id: user.id, project: project2) }
let(:issue3) { create(:issue, assignee_id: user2.id, project: project2) }
end
end
+ let(:u_watcher) { create(:user, notification_level: Notification::N_WATCH) }
+ let(:u_participating) { create(:user, notification_level: Notification::N_PARTICIPATING) }
+ let(:u_disabled) { create(:user, notification_level: Notification::N_DISABLED) }
+ let(:u_mentioned) { create(:user, username: 'mention', notification_level: Notification::N_WATCH) }
+
def build_team(project)
- @u_watcher = create(:user, notification_level: Notification::N_WATCH)
- @u_participating = create(:user, notification_level: Notification::N_PARTICIPATING)
- @u_disabled = create(:user, notification_level: Notification::N_DISABLED)
- @u_mentioned = create(:user, username: 'mention', notification_level: Notification::N_WATCH)
+ @u_watcher = u_watcher
+ @u_participating = u_participating
+ @u_disabled = u_disabled
+ @u_mentioned = u_mentioned
project.team << [@u_watcher, :master]
project.team << [@u_participating, :master]