Skip to content

Commit

Permalink
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaporozhets committed Jun 9, 2015
2 parents 4e9de95 + 18e33e0 commit 9562f02
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
8 changes: 7 additions & 1 deletion app/models/concerns/mentionable.rb
Expand Up @@ -67,7 +67,13 @@ def references(p = project, current_user = self.author, text = mentionable_text)

# 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
Expand Down
2 changes: 0 additions & 2 deletions app/views/layouts/_head.html.haml
Expand Up @@ -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
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.haml
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/project.html.haml
Expand Up @@ -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)}";
Expand Down
1 change: 1 addition & 0 deletions doc_styleguide.md
Expand Up @@ -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

Expand Down
21 changes: 19 additions & 2 deletions 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

0 comments on commit 9562f02

Please sign in to comment.