BigW Consortium Gitlab

Commit a540f55c by Douwe Maan

Fix specs

parent b181d312
......@@ -89,7 +89,7 @@ module NotesActions
if note.persisted?
attrs[:valid] = true
if noteable.discussions_rendered_on_frontend?
if noteable.nil? || noteable.discussions_rendered_on_frontend?
attrs.merge!(note_serializer.represent(note))
else
attrs.merge!(
......
......@@ -300,7 +300,7 @@ class Note < ActiveRecord::Base
end
def expire_etag_cache
return unless noteable.discussions_rendered_on_frontend?
return unless noteable&.discussions_rendered_on_frontend?
key = Gitlab::Routing.url_helpers.project_noteable_notes_path(
project,
......
......@@ -14,8 +14,8 @@ class NoteEntity < API::Entities::Note
expose :redacted_note_html, as: :note_html
expose :last_edited_at, if: -> (note, _) { note.is_edited? }
expose :last_edited_by, using: NoteUserEntity, if: -> (note, _) { note.is_edited? }
expose :last_edited_at, if: -> (note, _) { note.edited? }
expose :last_edited_by, using: NoteUserEntity, if: -> (note, _) { note.edited? }
expose :current_user do
expose :can_edit do |note|
......
......@@ -46,10 +46,13 @@ describe Projects::NotesController do
end
context 'for a discussion note' do
let!(:note) { create(:discussion_note_on_issue, noteable: issue, project: project) }
let(:project) { create(:project, :repository) }
let!(:note) { create(:discussion_note_on_merge_request, project: project) }
let(:params) { request_params.merge(target_type: 'merge_request', target_id: note.noteable_id) }
it 'responds with the expected attributes' do
get :index, request_params
get :index, params
expect(note_json[:id]).to eq(note.id)
expect(note_json[:discussion_html]).not_to be_nil
......@@ -104,10 +107,12 @@ describe Projects::NotesController do
end
context 'for a regular note' do
let!(:note) { create(:note, noteable: issue, project: project) }
let!(:note) { create(:note_on_merge_request, project: project) }
let(:params) { request_params.merge(target_type: 'merge_request', target_id: note.noteable_id) }
it 'responds with the expected attributes' do
get :index, request_params
get :index, params
expect(note_json[:id]).to eq(note.id)
expect(note_json[:html]).not_to be_nil
......@@ -125,7 +130,9 @@ describe Projects::NotesController do
note: { note: 'some note', noteable_id: merge_request.id, noteable_type: 'MergeRequest' },
namespace_id: project.namespace,
project_id: project,
merge_request_diff_head_sha: 'sha'
merge_request_diff_head_sha: 'sha',
target_type: 'merge_request',
target_id: merge_request.id
}
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