diff options
Diffstat (limited to 'spec/requests/api/services_spec.rb')
-rw-r--r-- | spec/requests/api/services_spec.rb | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index e260aa21e25..cb9552b0fe7 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -31,11 +31,11 @@ describe API::Services do it "returns if required fields missing" do attrs = service_attrs - required_attributes = service_attrs_list.select do |attr| + required_attributes = service_attrs_list.select { |attr| service_klass.validators_on(attr).any? do |v| v.class == ActiveRecord::Validations::PresenceValidator end - end + } if required_attributes.empty? expected_code = 200 @@ -74,7 +74,7 @@ describe API::Services do initialize_service(service) end - it 'returns authentication error when unauthenticated' do + it "returns authentication error when unauthenticated" do get api("/projects/#{project.id}/services/#{dashed_service}") expect(response).to have_gitlab_http_status(401) end @@ -83,14 +83,14 @@ describe API::Services do get api("/projects/#{project.id}/services/#{dashed_service}", admin) expect(response).to have_gitlab_http_status(200) - expect(json_response['properties'].keys).to match_array(service_instance.api_field_names) + expect(json_response["properties"].keys).to match_array(service_instance.api_field_names) end it "returns properties of service #{service} other than passwords when authenticated as project owner" do get api("/projects/#{project.id}/services/#{dashed_service}", user) expect(response).to have_gitlab_http_status(200) - expect(json_response['properties'].keys).to match_array(service_instance.api_field_names) + expect(json_response["properties"].keys).to match_array(service_instance.api_field_names) end it "returns error when authenticated but not a project owner" do @@ -102,12 +102,12 @@ describe API::Services do end end - describe 'POST /projects/:id/services/:slug/trigger' do - describe 'Mattermost Service' do - let(:service_name) { 'mattermost_slash_commands' } + describe "POST /projects/:id/services/:slug/trigger" do + describe "Mattermost Service" do + let(:service_name) { "mattermost_slash_commands" } - context 'no service is available' do - it 'returns a not found message' do + context "no service is available" do + it "returns a not found message" do post api("/projects/#{project.id}/services/idonotexist/trigger") expect(response).to have_gitlab_http_status(404) @@ -115,10 +115,10 @@ describe API::Services do end end - context 'the service exists' do - let(:params) { { token: 'token' } } + context "the service exists" do + let(:params) { {token: "token"} } - context 'the service is not active' do + context "the service is not active" do before do project.create_mattermost_slash_commands_service( active: false, @@ -126,14 +126,14 @@ describe API::Services do ) end - it 'when the service is inactive' do + it "when the service is inactive" do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params expect(response).to have_gitlab_http_status(404) end end - context 'the service is active' do + context "the service is active" do before do project.create_mattermost_slash_commands_service( active: true, @@ -141,15 +141,15 @@ describe API::Services do ) end - it 'returns status 200' do + it "returns status 200" do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params expect(response).to have_gitlab_http_status(200) end end - context 'when the project can not be found' do - it 'returns a generic 404' do + context "when the project can not be found" do + it "returns a generic 404" do post api("/projects/404/services/#{service_name}/trigger"), params: params expect(response).to have_gitlab_http_status(404) @@ -159,29 +159,29 @@ describe API::Services do end end - describe 'Slack Service' do - let(:service_name) { 'slack_slash_commands' } + describe "Slack Service" do + let(:service_name) { "slack_slash_commands" } before do project.create_slack_slash_commands_service( active: true, - properties: { token: 'token' } + properties: {token: "token"} ) end - it 'returns status 200' do - post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: { token: 'token', text: 'help' } + it "returns status 200" do + post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: {token: "token", text: "help"} expect(response).to have_gitlab_http_status(200) - expect(json_response['response_type']).to eq("ephemeral") + expect(json_response["response_type"]).to eq("ephemeral") end end end - describe 'Mattermost service' do - let(:service_name) { 'mattermost' } + describe "Mattermost service" do + let(:service_name) { "mattermost" } let(:params) do - { webhook: 'https://hook.example.com', username: 'username' } + {webhook: "https://hook.example.com", username: "username"} end before do @@ -191,11 +191,11 @@ describe API::Services do ) end - it 'accepts a username for update' do - put api("/projects/#{project.id}/services/mattermost", user), params: params.merge(username: 'new_username') + it "accepts a username for update" do + put api("/projects/#{project.id}/services/mattermost", user), params: params.merge(username: "new_username") expect(response).to have_gitlab_http_status(200) - expect(json_response['properties']['username']).to eq('new_username') + expect(json_response["properties"]["username"]).to eq("new_username") end end end |