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 ...@@ -234,7 +234,7 @@ module IssuablesHelper
data.merge!(updated_at_by(issuable)) data.merge!(updated_at_by(issuable))
data.to_json data
end end
def updated_at_by(issuable) def updated_at_by(issuable)
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
.issue-details.issuable-details .issue-details.issuable-details
.detail-page-description.content-block .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 #js-issuable-app
%h2.title= markdown_field(@issue, :title) %h2.title= markdown_field(@issue, :title)
- if @issue.description.present? - if @issue.description.present?
......
...@@ -173,23 +173,23 @@ describe IssuablesHelper do ...@@ -173,23 +173,23 @@ describe IssuablesHelper do
@project = issue.project @project = issue.project
expected_data = { expected_data = {
'endpoint' => "/#{@project.full_path}/issues/#{issue.iid}", endpoint: "/#{@project.full_path}/issues/#{issue.iid}",
'updateEndpoint' => "/#{@project.full_path}/issues/#{issue.iid}.json", updateEndpoint: "/#{@project.full_path}/issues/#{issue.iid}.json",
'canUpdate' => true, canUpdate: true,
'canDestroy' => true, canDestroy: true,
'issuableRef' => "##{issue.iid}", issuableRef: "##{issue.iid}",
'markdownPreviewPath' => "/#{@project.full_path}/preview_markdown", markdownPreviewPath: "/#{@project.full_path}/preview_markdown",
'markdownDocsPath' => '/help/user/markdown', markdownDocsPath: '/help/user/markdown',
'issuableTemplates' => [], issuableTemplates: [],
'projectPath' => @project.path, projectPath: @project.path,
'projectNamespace' => @project.namespace.path, projectNamespace: @project.namespace.path,
'initialTitleHtml' => issue.title, initialTitleHtml: issue.title,
'initialTitleText' => issue.title, initialTitleText: issue.title,
'initialDescriptionHtml' => '<p dir="auto">issue text</p>', initialDescriptionHtml: '<p dir="auto">issue text</p>',
'initialDescriptionText' => 'issue text', initialDescriptionText: 'issue text',
'initialTaskStatus' => '0 of 0 tasks completed' 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
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