Commit 2bec7e60 authored by Miguel Rincon's avatar Miguel Rincon

Define group runners attributes helper

This change moves the definition of data-* attributes to a helper that
can be tested in isolation, this helps ensure data is correctly
provided to the HTML container that mounts the Vue application.
parent 87a9f83c
......@@ -65,6 +65,15 @@ module Ci
}
end
def group_runners_data_attributes(group)
{
registration_token: group.runners_token,
group_id: group.id,
group_full_path: group.full_path,
runner_install_help_page: 'https://docs.gitlab.com/runner/install/'
}
end
def toggle_shared_runners_settings_data(project)
{
is_enabled: "#{project.shared_runners_enabled?}",
......
......@@ -3,4 +3,4 @@
%h2.page-title
= s_('Runners|Group Runners')
#js-group-runners{ data: { registration_token: @group.runners_token, runner_install_help_page: 'https://docs.gitlab.com/runner/install/', group_id: @group.id, group_full_path: @group.full_path, group_runners_limited_count: @group_runners_limited_count } }
#js-group-runners{ data: group_runners_data_attributes(@group).merge( { group_runners_limited_count: @group_runners_limited_count } ) }
......@@ -88,6 +88,19 @@ RSpec.describe Ci::RunnersHelper do
end
end
describe '#group_runners_data_attributes' do
let(:group) { create(:group) }
it 'returns group data to render a runner list' do
data = group_runners_data_attributes(group)
expect(data[:registration_token]).to eq(group.runners_token)
expect(data[:group_id]).to eq(group.id)
expect(data[:group_full_path]).to eq(group.full_path)
expect(data[:runner_install_help_page]).to eq('https://docs.gitlab.com/runner/install/')
end
end
describe '#toggle_shared_runners_settings_data' do
let_it_be(:group) { create(:group) }
......
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