Commit e8a4ee8a authored by Igor's avatar Igor Committed by Stan Hu

Fix sharing localStorage with all MRs

Expose id field in the serializer in order
to store comments content in the localStorage
under the correct key
parent 05fca5ff
# frozen_string_literal: true # frozen_string_literal: true
class MergeRequestNoteableEntity < Grape::Entity class MergeRequestNoteableEntity < IssuableEntity
include RequestAwareEntity include RequestAwareEntity
# Currently this attr is exposed to be used in app/assets/javascripts/notes/stores/getters.js # Currently this attr is exposed to be used in app/assets/javascripts/notes/stores/getters.js
......
---
title: Fix sharing localStorage with all MRs
merge_request: 32699
author:
type: fixed
...@@ -5,7 +5,8 @@ require 'spec_helper' ...@@ -5,7 +5,8 @@ require 'spec_helper'
describe 'Merge request > User posts notes', :js do describe 'Merge request > User posts notes', :js do
include NoteInteractionHelpers include NoteInteractionHelpers
let(:project) { create(:project, :repository) } set(:project) { create(:project, :repository) }
let(:user) { project.creator } let(:user) { project.creator }
let(:merge_request) do let(:merge_request) do
create(:merge_request, source_project: project, target_project: project) create(:merge_request, source_project: project, target_project: project)
...@@ -33,17 +34,21 @@ describe 'Merge request > User posts notes', :js do ...@@ -33,17 +34,21 @@ describe 'Merge request > User posts notes', :js do
end end
describe 'with text' do describe 'with text' do
let(:text) { 'This is awesome' }
before do before do
page.within('.js-main-target-form') do page.within('.js-main-target-form') do
fill_in 'note[note]', with: 'This is awesome' fill_in 'note[note]', with: text
end end
end end
it 'has enable submit button and preview button' do it 'has enable submit button, preview button and saves content to local storage' do
page.within('.js-main-target-form') do page.within('.js-main-target-form') do
expect(page).not_to have_css('.js-comment-button[disabled]') expect(page).not_to have_css('.js-comment-button[disabled]')
expect(page).to have_css('.js-md-preview-button', visible: true) expect(page).to have_css('.js-md-preview-button', visible: true)
end end
expect(page.evaluate_script("localStorage['autosave/Note/MergeRequest/#{merge_request.id}']")).to eq(text)
end end
end end
end end
......
{ {
"type": "object", "type": "object",
"properties" : { "properties" : {
"id": { "type": "integer" },
"iid": { "type": "integer" },
"title": { "type": "string" },
"description": { "type": "string" },
"merge_params": { "type": ["object", "null"] }, "merge_params": { "type": ["object", "null"] },
"state": { "type": "string" }, "state": { "type": "string" },
"source_branch": { "type": "string" }, "source_branch": { "type": "string" },
......
require 'spec_helper' require 'spec_helper'
describe MergeRequestSerializer do describe MergeRequestSerializer do
let(:user) { create(:user) } set(:user) { create(:user) }
let(:resource) { create(:merge_request) } set(:resource) { create(:merge_request, description: "Description") }
let(:json_entity) do let(:json_entity) do
described_class.new(current_user: user) described_class.new(current_user: user)
.represent(resource, serializer: serializer) .represent(resource, serializer: serializer)
......
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