diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-09 12:40:00 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-09 12:40:00 +0200 |
commit | 9562f028594c6d61834d48f75f8379b0de2ba8ae (patch) | |
tree | cc276b36d56253cc57a86f22490365cdee680650 | |
parent | 4e9de9522158e55a2e430c83c2968936f5bbc511 (diff) | |
parent | 18e33e037f15810a5a767522155d46839db94d50 (diff) | |
download | gitlab-ce-9562f028594c6d61834d48f75f8379b0de2ba8ae.tar.gz |
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
-rw-r--r-- | app/models/concerns/mentionable.rb | 8 | ||||
-rw-r--r-- | app/views/layouts/_head.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/application.html.haml | 3 | ||||
-rw-r--r-- | app/views/layouts/project.html.haml | 4 | ||||
-rw-r--r-- | doc_styleguide.md | 1 | ||||
-rw-r--r-- | spec/models/concerns/mentionable_spec.rb | 21 |
6 files changed, 32 insertions, 7 deletions
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index 6f9f54d08cc..10c39cb1ece 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -67,7 +67,13 @@ module Mentionable # Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+. def create_cross_references!(p = project, a = author, without = []) - refs = references(p) - without + refs = references(p) + + # We're using this method instead of Array diffing because that requires + # both of the object's `hash` values to be the same, which may not be the + # case for otherwise identical Commit objects. + refs.reject! { |ref| without.include?(ref) } + refs.each do |ref| Note.create_cross_reference_note(ref, local_reference, a) end diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 4d8c5656a25..dbc68c39bf1 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -20,5 +20,3 @@ = render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id') = render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id') = render 'layouts/bootlint' if Rails.env.development? - - = yield :scripts_head diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index ff23913d7d6..173033f7eab 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,6 +2,9 @@ %html{ lang: "en"} = render "layouts/head" %body{class: "#{app_theme}", :'data-page' => body_data_page} + / Ideally this would be inside the head, but turbolinks only evaluates page-specific JS in the body. + = yield :scripts_body_top + - if current_user = render "layouts/header/default", title: header_title - else diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index 03c7ba8c73f..44afa33dfe5 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -2,8 +2,8 @@ - header_title project_title(@project) - sidebar "project" unless sidebar -- content_for :scripts_head do - -if current_user +- content_for :scripts_body_top do + - if current_user :javascript window.project_uploads_path = "#{namespace_project_uploads_path @project.namespace, @project}"; window.markdown_preview_path = "#{markdown_preview_namespace_project_path(@project.namespace, @project)}"; diff --git a/doc_styleguide.md b/doc_styleguide.md index 670af765f3a..db30a737f14 100644 --- a/doc_styleguide.md +++ b/doc_styleguide.md @@ -12,6 +12,7 @@ This styleguide recommends best practices to improve documentation and to keep i * Be brief and clear. +* Whenever it applies, add documents in alphabetical order. ## When adding images to a document diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb index eadb941a3fa..22237f2e9f2 100644 --- a/spec/models/concerns/mentionable_spec.rb +++ b/spec/models/concerns/mentionable_spec.rb @@ -1,14 +1,31 @@ require 'spec_helper' describe Issue, "Mentionable" do - describe :mentioned_users do + describe '#mentioned_users' do let!(:user) { create(:user, username: 'stranger') } let!(:user2) { create(:user, username: 'john') } - let!(:issue) { create(:issue, description: '@stranger mentioned') } + let!(:issue) { create(:issue, description: "#{user.to_reference} mentioned") } subject { issue.mentioned_users } it { is_expected.to include(user) } it { is_expected.not_to include(user2) } end + + describe '#create_cross_references!' do + let(:project) { create(:project) } + let(:author) { double('author') } + let(:commit) { project.commit } + let(:commit2) { project.commit } + + let!(:issue) do + create(:issue, project: project, description: commit.to_reference) + end + + it 'correctly removes already-mentioned Commits' do + expect(Note).not_to receive(:create_cross_reference_note) + + issue.create_cross_references!(project, author, [commit2]) + end + end end |