summaryrefslogtreecommitdiff
path: root/spec/features/projects/services/user_activates_slack_slash_command_spec.rb
blob: 08cfddf7993ce1308b00779900c0714fc49b8371 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'spec_helper'

describe 'Slack slash commands' do
  let(:user) { create(:user) }
  let(:project) { create(:project) }
  let(:service) { project.create_slack_slash_commands_service }

  before do
    project.add_maintainer(user)
    sign_in(user)
    visit edit_project_service_path(project, service)
  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

  it 'redirects to the integrations page after saving but not activating' do
    fill_in 'service_token', with: 'token'
    click_on 'Save'

    expect(current_path).to eq(project_settings_integrations_path(project))
    expect(page).to have_content('Slack slash commands settings saved, but not activated.')
  end

  it 'redirects to the integrations page after activating' do
    fill_in 'service_token', with: 'token'
    check 'service_active'
    click_on 'Save'

    expect(current_path).to eq(project_settings_integrations_path(project))
    expect(page).to have_content('Slack slash commands activated.')
  end

  it 'shows the correct trigger url' do
    value = find_field('url').value
    expect(value).to match("api/v4/projects/#{project.id}/services/slack_slash_commands/trigger")
  end
end