debian-mirror-gitlab/spec/features/projects/services/user_activates_slack_slash_command_spec.rb

47 lines
1.4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2018-11-08 19:23:39 +05:30
describe 'Slack slash commands' do
let(:user) { create(:user) }
let(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2017-09-10 17:25:29 +05:30
sign_in(user)
2020-04-22 19:07:51 +05:30
visit edit_project_service_path(project, :slack_slash_commands)
2017-08-17 22:00:37 +05:30
end
it 'shows a token placeholder' do
token_placeholder = find_field('service_token')['placeholder']
expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
end
it 'shows a help message' do
expect(page).to have_content('This service allows users to perform common')
end
2020-04-22 19:07:51 +05:30
it 'redirects to the integrations page after saving but not activating', :js do
2017-08-17 22:00:37 +05:30
fill_in 'service_token', with: 'token'
2020-04-22 19:07:51 +05:30
find('input[name="service[active]"] + button').click
2017-08-17 22:00:37 +05:30
click_on 'Save'
2017-09-10 17:25:29 +05:30
expect(current_path).to eq(project_settings_integrations_path(project))
expect(page).to have_content('Slack slash commands settings saved, but not activated.')
end
2020-04-22 19:07:51 +05:30
it 'redirects to the integrations page after activating', :js do
2017-09-10 17:25:29 +05:30
fill_in 'service_token', with: 'token'
click_on 'Save'
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(current_path).to eq(project_settings_integrations_path(project))
expect(page).to have_content('Slack slash commands activated.')
2017-08-17 22:00:37 +05:30
end
it 'shows the correct trigger url' do
value = find_field('url').value
2017-09-10 17:25:29 +05:30
expect(value).to match("api/v4/projects/#{project.id}/services/slack_slash_commands/trigger")
2017-08-17 22:00:37 +05:30
end
end