Commit 41a5adca authored by Lin Jen-Shin's avatar Lin Jen-Shin

Don't try to create diffs if one of the branch is missing

Also fix a few tests
parent 8730cd86
...@@ -443,7 +443,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -443,7 +443,8 @@ class MergeRequest < ActiveRecord::Base
end end
def reload_diff_if_branch_changed def reload_diff_if_branch_changed
if source_branch_changed? || target_branch_changed? if (source_branch_changed? || target_branch_changed?) &&
(source_branch_head && target_branch_head)
reload_diff reload_diff
end end
end end
......
...@@ -841,7 +841,7 @@ describe Projects::IssuesController do ...@@ -841,7 +841,7 @@ describe Projects::IssuesController do
describe 'POST #toggle_award_emoji' do describe 'POST #toggle_award_emoji' do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it "toggles the award emoji" do it "toggles the award emoji" do
......
require 'rails_helper' require 'rails_helper'
feature 'Merge Request filtering by Labels', js: true do feature 'Merge Request filtering by Labels', :js do
include FilteredSearchHelpers include FilteredSearchHelpers
include MergeRequestHelpers include MergeRequestHelpers
...@@ -12,9 +12,9 @@ feature 'Merge Request filtering by Labels', js: true do ...@@ -12,9 +12,9 @@ feature 'Merge Request filtering by Labels', js: true do
let!(:feature) { create(:label, project: project, title: 'feature') } let!(:feature) { create(:label, project: project, title: 'feature') }
let!(:enhancement) { create(:label, project: project, title: 'enhancement') } let!(:enhancement) { create(:label, project: project, title: 'enhancement') }
let!(:mr1) { create(:merge_request, title: "Bugfix1", source_project: project, target_project: project, source_branch: "bugfix1") } let!(:mr1) { create(:merge_request, title: "Bugfix1", source_project: project, target_project: project, source_branch: "fix") }
let!(:mr2) { create(:merge_request, title: "Bugfix2", source_project: project, target_project: project, source_branch: "bugfix2") } let!(:mr2) { create(:merge_request, title: "Bugfix2", source_project: project, target_project: project, source_branch: "wip") }
let!(:mr3) { create(:merge_request, title: "Feature1", source_project: project, target_project: project, source_branch: "feature1") } let!(:mr3) { create(:merge_request, title: "Feature1", source_project: project, target_project: project, source_branch: "improve/awesome") }
before do before do
mr1.labels << bug mr1.labels << bug
...@@ -25,7 +25,7 @@ feature 'Merge Request filtering by Labels', js: true do ...@@ -25,7 +25,7 @@ feature 'Merge Request filtering by Labels', js: true do
mr3.title = "Feature1" mr3.title = "Feature1"
mr3.labels << feature mr3.labels << feature
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
visit project_merge_requests_path(project) visit project_merge_requests_path(project)
......
...@@ -24,12 +24,10 @@ describe 'Projects > Merge requests > User lists merge requests' do ...@@ -24,12 +24,10 @@ describe 'Projects > Merge requests > User lists merge requests' do
milestone: create(:milestone, due_date: '2013-12-12'), milestone: create(:milestone, due_date: '2013-12-12'),
created_at: 2.minutes.ago, created_at: 2.minutes.ago,
updated_at: 2.minutes.ago) updated_at: 2.minutes.ago)
# lfs in itself is not a great choice for the title if one wants to match the whole body content later on
# just think about the scenario when faker generates 'Chester Runolfsson' as the user's name
create(:merge_request, create(:merge_request,
title: 'merge_lfs', title: 'merge-test',
source_project: project, source_project: project,
source_branch: 'merge_lfs', source_branch: 'merge-test',
created_at: 3.minutes.ago, created_at: 3.minutes.ago,
updated_at: 10.seconds.ago) updated_at: 10.seconds.ago)
end end
...@@ -38,7 +36,7 @@ describe 'Projects > Merge requests > User lists merge requests' do ...@@ -38,7 +36,7 @@ describe 'Projects > Merge requests > User lists merge requests' do
visit_merge_requests(project, assignee_id: IssuableFinder::NONE) visit_merge_requests(project, assignee_id: IssuableFinder::NONE)
expect(current_path).to eq(project_merge_requests_path(project)) expect(current_path).to eq(project_merge_requests_path(project))
expect(page).to have_content 'merge_lfs' expect(page).to have_content 'merge-test'
expect(page).not_to have_content 'fix' expect(page).not_to have_content 'fix'
expect(page).not_to have_content 'markdown' expect(page).not_to have_content 'markdown'
expect(count_merge_requests).to eq(1) expect(count_merge_requests).to eq(1)
...@@ -47,7 +45,7 @@ describe 'Projects > Merge requests > User lists merge requests' do ...@@ -47,7 +45,7 @@ describe 'Projects > Merge requests > User lists merge requests' do
it 'filters on a specific assignee' do it 'filters on a specific assignee' do
visit_merge_requests(project, assignee_id: user.id) visit_merge_requests(project, assignee_id: user.id)
expect(page).not_to have_content 'merge_lfs' expect(page).not_to have_content 'merge-test'
expect(page).to have_content 'fix' expect(page).to have_content 'fix'
expect(page).to have_content 'markdown' expect(page).to have_content 'markdown'
expect(count_merge_requests).to eq(2) expect(count_merge_requests).to eq(2)
...@@ -57,14 +55,14 @@ describe 'Projects > Merge requests > User lists merge requests' do ...@@ -57,14 +55,14 @@ describe 'Projects > Merge requests > User lists merge requests' do
visit_merge_requests(project, sort: sort_value_recently_created) visit_merge_requests(project, sort: sort_value_recently_created)
expect(first_merge_request).to include('fix') expect(first_merge_request).to include('fix')
expect(last_merge_request).to include('merge_lfs') expect(last_merge_request).to include('merge-test')
expect(count_merge_requests).to eq(3) expect(count_merge_requests).to eq(3)
end end
it 'sorts by oldest' do it 'sorts by oldest' do
visit_merge_requests(project, sort: sort_value_oldest_created) visit_merge_requests(project, sort: sort_value_oldest_created)
expect(first_merge_request).to include('merge_lfs') expect(first_merge_request).to include('merge-test')
expect(last_merge_request).to include('fix') expect(last_merge_request).to include('fix')
expect(count_merge_requests).to eq(3) expect(count_merge_requests).to eq(3)
end end
...@@ -72,7 +70,7 @@ describe 'Projects > Merge requests > User lists merge requests' do ...@@ -72,7 +70,7 @@ describe 'Projects > Merge requests > User lists merge requests' do
it 'sorts by last updated' do it 'sorts by last updated' do
visit_merge_requests(project, sort: sort_value_recently_updated) visit_merge_requests(project, sort: sort_value_recently_updated)
expect(first_merge_request).to include('merge_lfs') expect(first_merge_request).to include('merge-test')
expect(count_merge_requests).to eq(3) expect(count_merge_requests).to eq(3)
end end
......
...@@ -12,7 +12,7 @@ describe EnvironmentsFinder do ...@@ -12,7 +12,7 @@ describe EnvironmentsFinder do
context 'tagged deployment' do context 'tagged deployment' do
before do before do
create(:deployment, environment: environment, ref: '1.0', tag: true, sha: project.commit.id) create(:deployment, environment: environment, ref: 'v1.1.0', tag: true, sha: project.commit.id)
end end
it 'returns environment when with_tags is set' do it 'returns environment when with_tags is set' do
......
...@@ -1196,9 +1196,8 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -1196,9 +1196,8 @@ describe Gitlab::Git::Repository, seed_helper: true do
def create_remote_branch(repository, remote_name, branch_name, source_branch_name) def create_remote_branch(repository, remote_name, branch_name, source_branch_name)
source_branch = repository.branches.find { |branch| branch.name == source_branch_name } source_branch = repository.branches.find { |branch| branch.name == source_branch_name }
repository.write_ref( rugged = repository.rugged
"refs/remotes/#{remote_name}/#{branch_name}", rugged.references.create("refs/remotes/#{remote_name}/#{branch_name}", source_branch.dereferenced_target.sha)
source_branch.dereferenced_target.sha)
end end
# Build the options hash that's passed to Rugged::Commit#create # Build the options hash that's passed to Rugged::Commit#create
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment