Commit 6d1fca0e authored by Mark Chao's avatar Mark Chao

Update page epic init data to include new date fields

parent bad81180
......@@ -16,11 +16,23 @@ module EpicsHelper
todo_exists: todo.present?,
todo_path: group_todos_path(group),
start_date: epic.start_date,
due_date: epic.due_date,
end_date: epic.end_date
}
epic_meta[:todo_delete_path] = dashboard_todo_path(todo) if todo.present?
if Ability.allowed?(current_user, :update_epic, epic.group)
epic_meta.merge!(
start_date_fixed: epic.start_date_fixed,
start_date_is_fixed: epic.start_date_is_fixed?,
start_date_from_milestones: epic.start_date_from_milestones,
due_date_fixed: epic.due_date_fixed,
due_date_is_fixed: epic.due_date_is_fixed?,
due_date_from_milestones: epic.due_date_from_milestones
)
end
participants = UserSerializer.new.represent(epic.participants)
initial = opts[:initial].merge(labels: epic.labels,
participants: participants,
......
......@@ -4,18 +4,21 @@ describe EpicsHelper do
include ApplicationHelper
describe '#epic_show_app_data' do
it 'returns the correct json' do
user = create(:user)
@epic = create(:epic, author: user)
let(:user) { create(:user) }
let!(:epic) { create(:epic, author: user) }
before do
allow(helper).to receive(:current_user).and_return(user)
stub_licensed_features(epics: true)
end
data = helper.epic_show_app_data(@epic, initial: {}, author_icon: 'icon_path')
it 'returns the correct json' do
data = helper.epic_show_app_data(epic, initial: {}, author_icon: 'icon_path')
meta_data = JSON.parse(data[:meta])
expected_keys = %i(initial meta namespace labels_path toggle_subscription_path labels_web_url epics_web_url)
expect(data.keys).to match_array(expected_keys)
expect(meta_data.keys).to match_array(%w[created author start_date end_date epic_id todo_exists todo_path])
expect(meta_data.keys).to match_array(%w[created author start_date end_date due_date epic_id todo_exists todo_path])
expect(meta_data['author']).to eq({
'name' => user.name,
'url' => "/#{user.username}",
......@@ -23,6 +26,23 @@ describe EpicsHelper do
'src' => 'icon_path'
})
end
context 'when user has edit permission' do
before do
epic.group.add_developer(user)
end
it 'returns extra date fields if user can edit' do
data = helper.epic_show_app_data(epic, initial: {}, author_icon: 'icon_path')
meta_data = JSON.parse(data[:meta])
expect(meta_data.keys).to match_array(%w[
created author
start_date start_date_fixed start_date_is_fixed start_date_from_milestones
end_date due_date due_date_fixed due_date_is_fixed due_date_from_milestones
])
end
end
end
describe '#epic_endpoint_query_params' do
......
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