Commit d9978902 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq into ce-to-ee

parents 811505c7 3d6d0e1e
...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.9.0 (unreleased) v 7.9.0 (unreleased)
- Fix merge request URL passed to Webhooks. (Stan Hu) - Fix merge request URL passed to Webhooks. (Stan Hu)
- Fix bug that caused a server error when editing a comment to "+1" or "-1" (Stan Hu)
- Move labels/milestones tabs to sidebar - Move labels/milestones tabs to sidebar
- Upgrade Rails gem to version 4.1.9. - Upgrade Rails gem to version 4.1.9.
- Improve error messages for file edit failures - Improve error messages for file edit failures
......
...@@ -3,10 +3,10 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -3,10 +3,10 @@ class Projects::NotesController < Projects::ApplicationController
before_filter :authorize_read_note! before_filter :authorize_read_note!
before_filter :authorize_write_note!, only: [:create] before_filter :authorize_write_note!, only: [:create]
before_filter :authorize_admin_note!, only: [:update, :destroy] before_filter :authorize_admin_note!, only: [:update, :destroy]
before_filter :find_current_user_notes, except: [:destroy, :delete_attachment]
def index def index
current_fetched_at = Time.now.to_i current_fetched_at = Time.now.to_i
@notes = NotesFinder.new.execute(project, current_user, params)
notes_json = { notes: [], last_fetched_at: current_fetched_at } notes_json = { notes: [], last_fetched_at: current_fetched_at }
...@@ -116,4 +116,10 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -116,4 +116,10 @@ class Projects::NotesController < Projects::ApplicationController
:attachment, :line_code, :commit_id :attachment, :line_code, :commit_id
) )
end end
private
def find_current_user_notes
@notes = NotesFinder.new.execute(project, current_user, params)
end
end end
...@@ -4,9 +4,9 @@ module NotesHelper ...@@ -4,9 +4,9 @@ module NotesHelper
(@noteable.class.name == note.noteable_type && !note.for_diff_line?) (@noteable.class.name == note.noteable_type && !note.for_diff_line?)
end end
def note_target_fields def note_target_fields(note)
hidden_field_tag(:target_type, @target_type) + hidden_field_tag(:target_type, note.noteable.class.name.underscore) +
hidden_field_tag(:target_id, @target_id) hidden_field_tag(:target_id, note.noteable.id)
end end
def link_to_commit_diff_line_note(note) def link_to_commit_diff_line_note(note)
......
.note-edit-form .note-edit-form
= form_for note, url: namespace_project_note_path(@project.namespace, @project, note), method: :put, remote: true, authenticity_token: true do |f| = form_for note, url: namespace_project_note_path(@project.namespace, @project, note), method: :put, remote: true, authenticity_token: true do |f|
= note_target_fields(note)
= render layout: 'projects/md_preview', locals: { preview_class: "note-text" } do = render layout: 'projects/md_preview', locals: { preview_class: "note-text" } do
= render 'projects/zen', f: f, attr: :note, = render 'projects/zen', f: f, attr: :note,
classes: 'note_text js-note-text' classes: 'note_text js-note-text'
......
= form_for [@project.namespace.becomes(Namespace), @project, @note], remote: true, html: { :'data-type' => 'json', multipart: true, id: nil, class: "new_note js-new-note-form common-note-form gfm-form" }, authenticity_token: true do |f| = form_for [@project.namespace.becomes(Namespace), @project, @note], remote: true, html: { :'data-type' => 'json', multipart: true, id: nil, class: "new_note js-new-note-form common-note-form gfm-form" }, authenticity_token: true do |f|
= note_target_fields = note_target_fields(@note)
= f.hidden_field :commit_id = f.hidden_field :commit_id
= f.hidden_field :line_code = f.hidden_field :line_code
= f.hidden_field :noteable_id = f.hidden_field :noteable_id
......
...@@ -41,3 +41,9 @@ Feature: Project Commits Comments ...@@ -41,3 +41,9 @@ Feature: Project Commits Comments
Given I leave a comment like "XML attached" Given I leave a comment like "XML attached"
And I delete a comment And I delete a comment
Then I should not see a comment saying "XML attached" Then I should not see a comment saying "XML attached"
@javascript
Scenario: I can edit a comment with +1
Given I leave a comment like "XML attached"
And I edit the last comment with a +1
Then I should see +1 in the description
...@@ -139,6 +139,15 @@ Feature: Project Issues ...@@ -139,6 +139,15 @@ Feature: Project Issues
And I leave a comment with task markdown And I leave a comment with task markdown
Then I should not see task checkboxes in the comment Then I should not see task checkboxes in the comment
@javascript
Scenario: Issue notes should be editable with +1
Given project "Shop" has "Tasks-open" open issue with task markdown
When I visit issue page "Tasks-open"
And I leave a comment with a header containing "Comment with a header"
Then The comment with the header should not have an ID
And I edit the last comment with a +1
Then I should see +1 in the description
# Task status in issues list # Task status in issues list
Scenario: Issues list should display task status Scenario: Issues list should display task status
......
...@@ -135,4 +135,21 @@ module SharedNote ...@@ -135,4 +135,21 @@ module SharedNote
'li.note div.timeline-content input[type="checkbox"]' 'li.note div.timeline-content input[type="checkbox"]'
) )
end end
step 'I edit the last comment with a +1' do
find(".note").hover
find('.js-note-edit').click
within(".current-note-edit-form") do
fill_in 'note[note]', with: '+1 Awesome!'
click_button 'Save Comment'
sleep 0.05
end
end
step 'I should see +1 in the description' do
within(".note") do
page.should have_content("+1 Awesome!")
end
end
end end
module Gitlab module Gitlab
class UrlBuilder class UrlBuilder
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
include GitlabRoutingHelper
def initialize(type) def initialize(type)
@type = type @type = type
...@@ -9,27 +10,22 @@ module Gitlab ...@@ -9,27 +10,22 @@ module Gitlab
def build(id) def build(id)
case @type case @type
when :issue when :issue
issue_url(id) build_issue_url(id)
when :merge_request when :merge_request
merge_request_url(id) build_merge_request_url(id)
end end
end end
private private
def issue_url(id) def build_issue_url(id)
issue = Issue.find(id) issue = Issue.find(id)
namespace_project_issue_url(namespace_id: issue.project.namespace, issue_url(issue, host: Gitlab.config.gitlab['url'])
id: issue.iid,
project_id: issue.project,
host: Gitlab.config.gitlab['url'])
end end
def merge_request_url(id) def build_merge_request_url(id)
merge_request = MergeRequest.find(id) merge_request = MergeRequest.find(id)
project_merge_request_url(id: merge_request.id, merge_request_url(merge_request, host: Gitlab.config.gitlab['url'])
project_id: merge_request.project,
host: Gitlab.config.gitlab['url'])
end end
end end
end end
...@@ -13,7 +13,7 @@ describe Gitlab::UrlBuilder do ...@@ -13,7 +13,7 @@ describe Gitlab::UrlBuilder do
it 'returns the merge request url' do it 'returns the merge request url' do
merge_request = create(:merge_request) merge_request = create(:merge_request)
url = Gitlab::UrlBuilder.new(:merge_request).build(merge_request.id) url = Gitlab::UrlBuilder.new(:merge_request).build(merge_request.id)
expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.to_param}/merge_requests/#{merge_request.id}" expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.path_with_namespace}/merge_requests/#{merge_request.iid}"
end end
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