Commit a1b819eb authored by Justin Ho's avatar Justin Ho

Fix lint issue and rename helper method

parent 73ed4b9a
......@@ -34,7 +34,7 @@ module EE
"https://slack.com/oauth/authorize?scope=commands&client_id=#{slack_app_id}&redirect_uri=#{slack_auth_project_settings_slack_url(project)}&state=#{escaped_form_authenticity_token}"
end
def add_to_slack_data(projects)
def gitlab_slack_application_data(projects)
{
projects: (projects || []).map { |p| serialize_project(p) }.to_json,
sign_in_path: new_session_path(:user, redirect_to_referer: 'yes'),
......
......@@ -3,4 +3,4 @@
- @content_class = 'limit-container-width'
- page_title s_('SlackIntegration|GitLab for Slack')
.js-gitlab-slack-application{ data: add_to_slack_data(@projects) }
.js-gitlab-slack-application{ data: gitlab_slack_application_data(@projects) }
......@@ -108,7 +108,7 @@ RSpec.describe EE::IntegrationsHelper do
end
end
describe '#add_to_slack_data' do
describe '#gitlab_slack_application_data' do
let_it_be(:projects) { create_list(:project, 3) }
def relation
......@@ -132,7 +132,7 @@ RSpec.describe EE::IntegrationsHelper do
end
it 'includes the required keys' do
additions = Gitlab::Json.parse(subject.add_to_slack_data(relation))
additions = subject.gitlab_slack_application_data(relation)
expect(additions.keys).to match_array %w[
projects
sign_in_path
......@@ -146,15 +146,15 @@ RSpec.describe EE::IntegrationsHelper do
end
it 'does not suffer from N+1 performance issues' do
baseline = ActiveRecord::QueryRecorder.new { subject.add_to_slack_data(relation.limit(1)) }
baseline = ActiveRecord::QueryRecorder.new { subject.gitlab_slack_application_data(relation.limit(1)) }
expect do
subject.add_to_slack_data(relation)
subject.gitlab_slack_application_data(relation)
end.not_to exceed_query_limit(baseline)
end
it 'serializes nil projects without error' do
expect(subject.add_to_slack_data(nil)).to include('"projects":null')
expect(subject.gitlab_slack_application_data(nil)).to include('"projects":null')
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