Commit 22addf26 authored by Jan Provaznik's avatar Jan Provaznik

Don't convert issuable_initial_data into JSON

Instead of converting hash into JSON inside
issuable_initial_data method, return hash and convert
to JSON later. This allows us to easily extend basic
issuable data with resource specific values. For example
for Epic these data should include also labels, so we can then
do something like:
issuable_initial_data(@epic).merge(labels: @epic.labels).to_json
parent 7eaafea2
......@@ -234,7 +234,7 @@ module IssuablesHelper
data.merge!(updated_at_by(issuable))
data.to_json
data
end
def updated_at_by(issuable)
......
......@@ -55,7 +55,7 @@
.issue-details.issuable-details
.detail-page-description.content-block
%script#js-issuable-app-initial-data{ type: "application/json" }= issuable_initial_data(@issue)
%script#js-issuable-app-initial-data{ type: "application/json" }= issuable_initial_data(@issue).to_json
#js-issuable-app
%h2.title= markdown_field(@issue, :title)
- if @issue.description.present?
......
......@@ -173,23 +173,23 @@ describe IssuablesHelper do
@project = issue.project
expected_data = {
'endpoint' => "/#{@project.full_path}/issues/#{issue.iid}",
'updateEndpoint' => "/#{@project.full_path}/issues/#{issue.iid}.json",
'canUpdate' => true,
'canDestroy' => true,
'issuableRef' => "##{issue.iid}",
'markdownPreviewPath' => "/#{@project.full_path}/preview_markdown",
'markdownDocsPath' => '/help/user/markdown',
'issuableTemplates' => [],
'projectPath' => @project.path,
'projectNamespace' => @project.namespace.path,
'initialTitleHtml' => issue.title,
'initialTitleText' => issue.title,
'initialDescriptionHtml' => '<p dir="auto">issue text</p>',
'initialDescriptionText' => 'issue text',
'initialTaskStatus' => '0 of 0 tasks completed'
endpoint: "/#{@project.full_path}/issues/#{issue.iid}",
updateEndpoint: "/#{@project.full_path}/issues/#{issue.iid}.json",
canUpdate: true,
canDestroy: true,
issuableRef: "##{issue.iid}",
markdownPreviewPath: "/#{@project.full_path}/preview_markdown",
markdownDocsPath: '/help/user/markdown',
issuableTemplates: [],
projectPath: @project.path,
projectNamespace: @project.namespace.path,
initialTitleHtml: issue.title,
initialTitleText: issue.title,
initialDescriptionHtml: '<p dir="auto">issue text</p>',
initialDescriptionText: 'issue text',
initialTaskStatus: '0 of 0 tasks completed'
}
expect(JSON.parse(helper.issuable_initial_data(issue))).to eq(expected_data)
expect(helper.issuable_initial_data(issue)).to eq(expected_data)
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