diff options
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | Gemfile.lock | 4 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/merge_requests_helper.rb | 3 | ||||
-rw-r--r-- | app/models/note.rb | 13 | ||||
-rw-r--r-- | app/views/groups/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/_home_panel.html.haml | 2 | ||||
-rw-r--r-- | features/project/merge_requests.feature | 6 | ||||
-rw-r--r-- | features/steps/project/merge_requests.rb | 18 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 20 | ||||
-rw-r--r-- | spec/requests/api/namespaces_spec.rb | 3 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 11 | ||||
-rw-r--r-- | spec/requests/api/users_spec.rb | 5 |
14 files changed, 69 insertions, 26 deletions
@@ -31,7 +31,7 @@ gem 'omniauth-shibboleth' # Extracting information from a git repository # Provide access to Gitlab::Git library -gem "gitlab_git", '7.0.0.rc8' +gem "gitlab_git", '7.0.0.rc9' # Ruby/Rack Git Smart-HTTP Server Handler gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' diff --git a/Gemfile.lock b/Gemfile.lock index 30e89e90d8f..babb23ed606 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,7 +179,7 @@ GEM mime-types (~> 1.19) gitlab_emoji (0.0.1.1) emoji (~> 1.0.1) - gitlab_git (7.0.0.rc8) + gitlab_git (7.0.0.rc9) activesupport (~> 4.0) charlock_holmes (~> 0.6) gitlab-linguist (~> 3.0) @@ -622,7 +622,7 @@ DEPENDENCIES gitlab-grack (~> 2.0.0.pre) gitlab-linguist (~> 3.0.0) gitlab_emoji (~> 0.0.1.1) - gitlab_git (= 7.0.0.rc8) + gitlab_git (= 7.0.0.rc9) gitlab_meta (= 7.0) gitlab_omniauth-ldap (= 1.1.0) gollum-lib (~> 3.0.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1a5215ca309..13d8d2a3e0a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base before_filter :configure_permitted_parameters, if: :devise_controller? before_filter :require_email, unless: :devise_controller? - protect_from_forgery + protect_from_forgery with: :exception helper_method :abilities, :can? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 34d312b4100..e8a9c2efadf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -259,4 +259,8 @@ module ApplicationHelper super end + + def escaped_autolink(text) + auto_link ERB::Util.html_escape(text), link: :urls + end end diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index d1ea47eb7b3..fe6fd5832fc 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -19,8 +19,7 @@ module MergeRequestsHelper source_project_id: event.project.id, target_project_id: target_project.id, source_branch: event.branch_name, - target_branch: target_project.repository.root_ref, - title: event.branch_name.titleize.humanize + target_branch: target_project.repository.root_ref } end diff --git a/app/models/note.rb b/app/models/note.rb index 0c1d792ca9a..6f1b1a4da94 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -47,7 +47,7 @@ class Note < ActiveRecord::Base scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) } scope :inline, ->{ where("line_code IS NOT NULL") } scope :not_inline, ->{ where(line_code: [nil, '']) } - + scope :system, ->{ where(system: true) } scope :common, ->{ where(noteable_type: ["", nil]) } scope :fresh, ->{ order("created_at ASC, id ASC") } scope :inc_author_project, ->{ includes(:project, :author) } @@ -168,9 +168,14 @@ class Note < ActiveRecord::Base # Determine whether or not a cross-reference note already exists. def cross_reference_exists?(noteable, mentioner) gfm_reference = mentioner_gfm_ref(noteable, mentioner) - - where(['noteable_id = ? and system = ? and note like ?', - noteable.id, true, "_mentioned in #{gfm_reference}_"]).any? + notes = if noteable.is_a?(Commit) + where(commit_id: noteable.id) + else + where(noteable_id: noteable.id) + end + + notes.where('note like ?', "_mentioned in #{gfm_reference}_"). + system.any? end def search(query) diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 4f4fc537d34..d876e87852c 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -24,7 +24,7 @@ = @group.name - if @group.description.present? %p - = auto_link @group.description, link: :urls + = escaped_autolink(@group.description) = render "projects", projects: @projects - if current_user .prepend-top-20 diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml index cdbdec698fa..672a91e0eef 100644 --- a/app/views/projects/_home_panel.html.haml +++ b/app/views/projects/_home_panel.html.haml @@ -3,7 +3,7 @@ .project-home-row .project-home-desc - if @project.description.present? - = auto_link ERB::Util.html_escape(@project.description), link: :urls + = escaped_autolink(@project.description) - if can?(current_user, :admin_project, @project) – = link_to 'Edit', edit_project_path diff --git a/features/project/merge_requests.feature b/features/project/merge_requests.feature index bad83191371..e1e0edd0545 100644 --- a/features/project/merge_requests.feature +++ b/features/project/merge_requests.feature @@ -115,7 +115,7 @@ Feature: Project Merge Requests And I switch to the diff tab And I leave a comment like "Line is wrong" on line 39 of the second file And I click link "Hide inline discussion" of the second file - Then I should not see a comment like "Line is wrong" in the second file + Then I should not see a comment like "Line is wrong here" in the second file @javascript Scenario: I show comments on a merge request diff with comments in a single file @@ -123,8 +123,6 @@ Feature: Project Merge Requests And I visit merge request page "Bug NS-05" And I switch to the diff tab And I leave a comment like "Line is wrong" on line 39 of the second file - And I click link "Hide inline discussion" of the second file - And I click link "Show inline discussion" of the second file Then I should see a comment like "Line is wrong" in the second file @javascript @@ -135,7 +133,7 @@ Feature: Project Merge Requests And I leave a comment like "Line is correct" on line 12 of the first file And I leave a comment like "Line is wrong" on line 39 of the second file And I click link "Hide inline discussion" of the second file - Then I should not see a comment like "Line is wrong" in the second file + Then I should not see a comment like "Line is wrong here" in the second file And I should still see a comment like "Line is correct" in the first file @javascript diff --git a/features/steps/project/merge_requests.rb b/features/steps/project/merge_requests.rb index 3e19616c166..0fec2604915 100644 --- a/features/steps/project/merge_requests.rb +++ b/features/steps/project/merge_requests.rb @@ -225,6 +225,18 @@ EOT end end + step 'I should not see a comment like "Line is wrong here" in the second file' do + within '.files [id^=diff]:nth-child(2)' do + page.should_not have_visible_content "Line is wrong here" + end + end + + step 'I should see a comment like "Line is wrong here" in the second file' do + within '.files [id^=diff]:nth-child(2) .note-text' do + page.should have_visible_content "Line is wrong here" + end + end + step 'I leave a comment like "Line is correct" on line 12 of the first file' do init_diff_note_first_file @@ -242,13 +254,9 @@ EOT init_diff_note_second_file within(".js-discussion-note-form") do - fill_in "note_note", with: "Line is wrong" + fill_in "note_note", with: "Line is wrong on here" click_button "Add Comment" end - - within ".files [id^=diff]:nth-child(2) .note-text" do - page.should have_content "Line is wrong" - end end step 'I should still see a comment like "Line is correct" in the first file' do diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index c88a03beb0c..eeecd714a28 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -258,6 +258,17 @@ describe Note do its(:commit_id) { should == commit.id } its(:note) { should == "_mentioned in issue ##{issue.iid}_" } end + + context 'commit from commit' do + let(:parent_commit) { commit.parents.first } + subject { Note.create_cross_reference_note(commit, parent_commit, author, project) } + + it { should be_valid } + its(:noteable_type) { should == "Commit" } + its(:noteable_id) { should be_nil } + its(:commit_id) { should == commit.id } + its(:note) { should == "_mentioned in commit #{parent_commit.id[0...6]}_" } + end end describe '#cross_reference_exists?' do @@ -278,6 +289,15 @@ describe Note do it 'detects if a mentionable has not already been mentioned' do Note.cross_reference_exists?(issue, commit1).should be_false end + + context 'commit on commit' do + before do + Note.create_cross_reference_note(commit0, commit1, author, project) + end + + it { Note.cross_reference_exists?(commit0, commit1).should be_true } + it { Note.cross_reference_exists?(commit1, commit0).should be_false } + end end describe '#system?' do diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb index d9d52468b15..b8943ea0762 100644 --- a/spec/requests/api/namespaces_spec.rb +++ b/spec/requests/api/namespaces_spec.rb @@ -20,8 +20,7 @@ describe API::API, api: true do response.status.should == 200 json_response.should be_an Array - # Admin namespace + 2 group namespaces - json_response.length.should == 3 + json_response.length.should == Namespace.count end end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 571d8506277..aa1437c71aa 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -54,8 +54,15 @@ describe API::API, api: true do get api("/projects/all", admin) response.status.should == 200 json_response.should be_an Array - json_response.first['name'].should == project.name - json_response.first['owner']['username'].should == user.username + project_name = project.name + + json_response.detect { + |project| project['name'] == project_name + }['name'].should == project_name + + json_response.detect { + |project| project['owner']['username'] == user.username + }['owner']['username'].should == user.username end end end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index b0752ebe43c..bc1598273be 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -20,7 +20,10 @@ describe API::API, api: true do get api("/users", user) response.status.should == 200 json_response.should be_an Array - json_response.first['username'].should == user.username + username = user.username + json_response.detect { + |user| user['username'] == username + }['username'].should == username end end |