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
class MergeRequestNoteableEntity < Grape::Entity
class MergeRequestNoteableEntity < IssuableEntity
include RequestAwareEntity
# 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'
describe 'Merge request > User posts notes', :js do
include NoteInteractionHelpers
let(:project) { create(:project, :repository) }
set(:project) { create(:project, :repository) }
let(:user) { project.creator }
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project)
......@@ -33,17 +34,21 @@ describe 'Merge request > User posts notes', :js do
end
describe 'with text' do
let(:text) { 'This is awesome' }
before do
page.within('.js-main-target-form') do
fill_in 'note[note]', with: 'This is awesome'
fill_in 'note[note]', with: text
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
expect(page).not_to have_css('.js-comment-button[disabled]')
expect(page).to have_css('.js-md-preview-button', visible: true)
end
expect(page.evaluate_script("localStorage['autosave/Note/MergeRequest/#{merge_request.id}']")).to eq(text)
end
end
end
......
{
"type": "object",
"properties" : {
"id": { "type": "integer" },
"iid": { "type": "integer" },
"title": { "type": "string" },
"description": { "type": "string" },
"merge_params": { "type": ["object", "null"] },
"state": { "type": "string" },
"source_branch": { "type": "string" },
......
require 'spec_helper'
describe MergeRequestSerializer do
let(:user) { create(:user) }
let(:resource) { create(:merge_request) }
set(:user) { create(:user) }
set(:resource) { create(:merge_request, description: "Description") }
let(:json_entity) do
described_class.new(current_user: user)
.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