Commit b888ed59 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Fixed issuables_helper_spec and added a test for issuable_app_data

parent 632d0c0a
......@@ -199,6 +199,29 @@ module IssuablesHelper
issuable_filter_params.any? { |k| params.key?(k) }
end
def issuable_app_data(project, issue)
data = {
endpoint: realtime_changes_namespace_project_issue_path(project.namespace, project, issue),
'can-update' => can?(current_user, :update_issue, issue).to_s,
'issuable-ref' => issue.to_reference || ''
}
updated_at_by = updated_at_by(issue)
data.merge(updated_at_by)
end
def updated_at_by(issuable)
return {} unless issuable.is_edited?
{
updated_at: issuable.updated_at.to_time.iso8601,
updated_by: {
name: issuable.last_edited_by.name,
path: user_path(issuable.last_edited_by)
}
}
end
private
def sidebar_gutter_collapsed?
......@@ -273,27 +296,4 @@ module IssuablesHelper
container: (is_collapsed ? 'body' : nil)
}
end
def issuable_app_data(project, issue)
data = {
endpoint: realtime_changes_namespace_project_issue_path(project.namespace, project, issue),
'can-update' => can?(current_user, :update_issue, issue).to_s,
'issuable-ref' => issue.to_reference || ''
}
updated_at_by = updated_at_by(issue)
data.merge(updated_at_by)
end
def updated_at_by(issuable)
return {} unless issuable.is_edited?
{
updated_at: issuable.updated_at.to_time.iso8601,
updated_by: {
name: issuable.last_edited_by.name,
path: user_path(issuable.last_edited_by)
}
}
end
end
......@@ -193,6 +193,32 @@ describe IssuablesHelper do
end
end
describe '#issuable_app_data' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project, last_edited_by: user, created_at: 3.days.ago, updated_at: 2.days.ago, last_edited_at: 2.days.ago) }
let(:issue_app_data) do
{
endpoint: realtime_changes_namespace_project_issue_path(project.namespace, project, issue),
'can-update' => "true",
'issuable-ref' => issue.to_reference || '',
updated_at: issue.updated_at.to_time.iso8601,
updated_by: {
name: user.name,
path: user_path(user)
}
}
end
before do
allow(helper).to receive(:current_user).and_return(nil)
allow(helper).to receive(:can?).with(nil, :update_issue, issue).and_return(true)
end
it { expect(helper.issuable_app_data(issue.project, issue)).to eq(issue_app_data) }
end
describe '#updated_at_by' do
let(:user) { create(:user) }
let(:unedited_issuable) { create(:issue) }
......
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