Commit 3568fd86 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'master' into 8-0-stable

parents f3837d05 eb5fd3f8
...@@ -16,11 +16,13 @@ class Projects::CompareController < Projects::ApplicationController ...@@ -16,11 +16,13 @@ class Projects::CompareController < Projects::ApplicationController
compare_result = CompareService.new. compare_result = CompareService.new.
execute(@project, head_ref, @project, base_ref) execute(@project, head_ref, @project, base_ref)
if compare_result
@commits = compare_result.commits @commits = compare_result.commits
@diffs = compare_result.diffs @diffs = compare_result.diffs
@commit = @commits.last @commit = @commits.last
@line_notes = [] @line_notes = []
end end
end
def create def create
redirect_to namespace_project_compare_path(@project.namespace, @project, redirect_to namespace_project_compare_path(@project.namespace, @project,
......
...@@ -4,7 +4,10 @@ require 'securerandom' ...@@ -4,7 +4,10 @@ require 'securerandom'
# and return Gitlab::CompareResult object that responds to commits and diffs # and return Gitlab::CompareResult object that responds to commits and diffs
class CompareService class CompareService
def execute(source_project, source_branch, target_project, target_branch) def execute(source_project, source_branch, target_project, target_branch)
source_sha = source_project.commit(source_branch).sha source_commit = source_project.commit(source_branch)
return unless source_commit
source_sha = source_commit.sha
# If compare with other project we need to fetch ref first # If compare with other project we need to fetch ref first
unless target_project == source_project unless target_project == source_project
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
.form-group.milestone-description .form-group.milestone-description
= f.label :description, "Description", class: "control-label" = f.label :description, "Description", class: "control-label"
.col-sm-10 .col-sm-10
= render layout: 'projects/md_preview', locals: { preview_class: "wiki" } do = render layout: 'projects/md_preview', locals: { preview_class: "md-preview" } do
= render 'projects/zen', f: f, attr: :description, classes: 'description form-control' = render 'projects/zen', f: f, attr: :description, classes: 'description form-control'
.hint .hint
.pull-left Milestones are parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"), target: '_blank'}. .pull-left Milestones are parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"), target: '_blank'}.
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
.form-group.wiki-content .form-group.wiki-content
= f.label :content, class: 'control-label' = f.label :content, class: 'control-label'
.col-sm-10 .col-sm-10
= render layout: 'projects/md_preview', locals: { preview_class: "wiki" } do = render layout: 'projects/md_preview', locals: { preview_class: "md-preview" } do
= render 'projects/zen', f: f, attr: :content, classes: 'description form-control' = render 'projects/zen', f: f, attr: :content, classes: 'description form-control'
.col-sm-12.hint .col-sm-12.hint
.pull-left Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"), target: '_blank'} .pull-left Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"), target: '_blank'}
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
= f.label :description, 'Description', class: 'control-label' = f.label :description, 'Description', class: 'control-label'
.col-sm-10 .col-sm-10
= render layout: 'projects/md_preview', locals: { preview_class: "wiki", referenced_users: true } do = render layout: 'projects/md_preview', locals: { preview_class: "md-preview", referenced_users: true } do
= render 'projects/zen', f: f, attr: :description, = render 'projects/zen', f: f, attr: :description,
classes: 'description form-control' classes: 'description form-control'
.col-sm-12.hint .col-sm-12.hint
......
This diff is collapsed.
...@@ -22,4 +22,30 @@ describe Projects::CompareController do ...@@ -22,4 +22,30 @@ describe Projects::CompareController do
expect(assigns(:diffs).length).to be >= 1 expect(assigns(:diffs).length).to be >= 1
expect(assigns(:commits).length).to be >= 1 expect(assigns(:commits).length).to be >= 1
end end
describe 'non-existent refs' do
it 'invalid source ref' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
from: 'non-existent',
to: ref_to)
expect(response).to be_success
expect(assigns(:diffs)).to eq([])
expect(assigns(:commits)).to eq([])
end
it 'invalid target ref' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
from: ref_from,
to: 'non-existent')
expect(response).to be_success
expect(assigns(:diffs)).to eq(nil)
expect(assigns(:commits)).to eq(nil)
end
end
end end
...@@ -38,7 +38,8 @@ describe Ci::Variable do ...@@ -38,7 +38,8 @@ describe Ci::Variable do
it 'fails to decrypt if iv is incorrect' do it 'fails to decrypt if iv is incorrect' do
subject.encrypted_value_iv = nil subject.encrypted_value_iv = nil
subject.instance_variable_set(:@value, nil) subject.instance_variable_set(:@value, nil)
expect { subject.value }.to raise_error expect { subject.value }.
to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt')
end end
end end
end end
...@@ -56,7 +56,8 @@ describe Ci::WebHook do ...@@ -56,7 +56,8 @@ describe Ci::WebHook do
it "catches exceptions" do it "catches exceptions" do
expect(Ci::WebHook).to receive(:post).and_raise("Some HTTP Post error") expect(Ci::WebHook).to receive(:post).and_raise("Some HTTP Post error")
expect{ @web_hook.execute(@data) }.to raise_error expect{ @web_hook.execute(@data) }.
to raise_error(RuntimeError, 'Some HTTP Post error')
end end
end end
end end
...@@ -165,7 +165,8 @@ describe Ci::API::API do ...@@ -165,7 +165,8 @@ describe Ci::API::API do
project.gl_project.team << [user, :master] project.gl_project.team << [user, :master]
delete ci_api("/projects/#{project.id}"), options delete ci_api("/projects/#{project.id}"), options
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect { project.reload }.to raise_error expect { project.reload }.
to raise_error(ActiveRecord::RecordNotFound)
end end
it "non-manager is not authorized" do it "non-manager is not authorized" do
......
...@@ -15,7 +15,8 @@ describe Ci::CreateProjectService do ...@@ -15,7 +15,8 @@ describe Ci::CreateProjectService do
context 'without project dump' do context 'without project dump' do
it 'should raise exception' do it 'should raise exception' do
expect { service.execute(current_user, '', '') }.to raise_error expect { service.execute(current_user, '', '') }.
to raise_error(NoMethodError)
end end
end end
......
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