Merge branch 'id-autosave-for-new-mr' into 'master'

Fix sharing notes data in localStorage with all MRs

See merge request gitlab-org/gitlab-ce!32699
This commit is contained in:
Stan Hu 2019-09-06 15:49:14 +00:00
commit 6dd99d8224
5 changed files with 21 additions and 6 deletions

View file

@ -1,6 +1,6 @@
# 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

View file

@ -0,0 +1,5 @@
---
title: Fix sharing localStorage with all MRs
merge_request: 32699
author:
type: fixed

View file

@ -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

View file

@ -1,6 +1,10 @@
{
"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" },

View file

@ -1,8 +1,9 @@
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)