Commit 632d0c0a authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Remove EditableHelper and move method to IssuablesHelper

parent 33d66a47
module EditableHelper
def updated_at_by(editable)
return {} unless editable.is_edited?
{
updated_at: editable.updated_at.to_time.iso8601,
updated_by: {
name: editable.last_edited_by.name,
path: user_path(editable.last_edited_by)
}
}
end
end
module IssuablesHelper
include GitlabRoutingHelper
include EditableHelper
def sidebar_gutter_toggle_icon
sidebar_gutter_collapsed? ? icon('angle-double-left', { 'aria-hidden': 'true' }) : icon('angle-double-right', { 'aria-hidden': 'true' })
......@@ -285,4 +284,16 @@ module IssuablesHelper
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
require 'spec_helper'
describe EditableHelper do
describe '#updated_at_by' do
let(:user) { create(:user) }
let(:unedited_editable) { create(:issue) }
let(:edited_editable) { create(:issue, last_edited_by: user, created_at: 3.days.ago, updated_at: 2.days.ago, last_edited_at: 2.days.ago) }
let(:edited_updated_at_by) do
{
updated_at: edited_editable.updated_at.to_time.iso8601,
updated_by: {
name: user.name,
path: user_path(user)
}
}
end
it { expect(helper.updated_at_by(unedited_editable)).to eq({}) }
it { expect(helper.updated_at_by(edited_editable)).to eq(edited_updated_at_by) }
end
end
......@@ -192,4 +192,22 @@ describe IssuablesHelper do
expect(helper.issuable_filter_present?).to be_falsey
end
end
describe '#updated_at_by' do
let(:user) { create(:user) }
let(:unedited_issuable) { create(:issue) }
let(:edited_issuable) { create(:issue, last_edited_by: user, created_at: 3.days.ago, updated_at: 2.days.ago, last_edited_at: 2.days.ago) }
let(:edited_updated_at_by) do
{
updated_at: edited_issuable.updated_at.to_time.iso8601,
updated_by: {
name: user.name,
path: user_path(user)
}
}
end
it { expect(helper.updated_at_by(unedited_issuable)).to eq({}) }
it { expect(helper.updated_at_by(edited_issuable)).to eq(edited_updated_at_by) }
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