summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-01-10 19:43:58 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-01-30 09:24:05 +0100
commitdc6921bdbbabd08be4426345140cb507b286eac7 (patch)
tree2c402abd7b9578019f36f4a0336b34acc646cf18 /spec/lib
parentb525aff665f139cd12ac5a6df78d722427e759cc (diff)
downloadgitlab-ce-dc6921bdbbabd08be4426345140cb507b286eac7.tar.gz
Chat Commands have presenters
This improves the styling and readability of the code. This is supported by both Mattermost and Slack.
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/chat_commands/command_spec.rb50
-rw-r--r--spec/lib/gitlab/chat_commands/deploy_spec.rb24
-rw-r--r--spec/lib/gitlab/chat_commands/issue_create_spec.rb12
-rw-r--r--spec/lib/gitlab/chat_commands/issue_search_spec.rb12
-rw-r--r--spec/lib/gitlab/chat_commands/issue_show_spec.rb25
-rw-r--r--spec/lib/gitlab/chat_commands/presenters/access_spec.rb49
-rw-r--r--spec/lib/gitlab/chat_commands/presenters/deploy_spec.rb47
-rw-r--r--spec/lib/gitlab/chat_commands/presenters/list_issues_spec.rb24
-rw-r--r--spec/lib/gitlab/chat_commands/presenters/show_issue_spec.rb27
-rw-r--r--spec/lib/mattermost/client_spec.rb24
-rw-r--r--spec/lib/mattermost/command_spec.rb61
-rw-r--r--spec/lib/mattermost/session_spec.rb123
-rw-r--r--spec/lib/mattermost/team_spec.rb66
13 files changed, 203 insertions, 341 deletions
diff --git a/spec/lib/gitlab/chat_commands/command_spec.rb b/spec/lib/gitlab/chat_commands/command_spec.rb
index 1e81eaef18c..d8b2303555c 100644
--- a/spec/lib/gitlab/chat_commands/command_spec.rb
+++ b/spec/lib/gitlab/chat_commands/command_spec.rb
@@ -5,6 +5,7 @@ describe Gitlab::ChatCommands::Command, service: true do
let(:user) { create(:user) }
describe '#execute' do
+<<<<<<< HEAD
subject do
described_class.new(project, user, params).execute
end
@@ -18,6 +19,9 @@ describe Gitlab::ChatCommands::Command, service: true do
expect(subject[:text]).to start_with('404 not found')
end
end
+=======
+ subject { described_class.new(project, user, params).execute }
+>>>>>>> Chat Commands have presenters
context 'when an unknown command is triggered' do
let(:params) { { command: '/gitlab', text: "unknown command 123" } }
@@ -34,47 +38,7 @@ describe Gitlab::ChatCommands::Command, service: true do
it 'rejects the actions' do
expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to start_with('Whoops! That action is not allowed')
- end
- end
-
- context 'issue is successfully created' do
- let(:params) { { text: "issue create my new issue" } }
-
- before do
- project.team << [user, :master]
- end
-
- it 'presents the issue' do
- expect(subject[:text]).to match("my new issue")
- end
-
- it 'shows a link to the new issue' do
- expect(subject[:text]).to match(/\/issues\/\d+/)
- end
- end
-
- context 'searching for an issue' do
- let(:params) { { text: 'issue search find me' } }
- let!(:issue) { create(:issue, project: project, title: 'find me') }
-
- before do
- project.team << [user, :master]
- end
-
- context 'a single issue is found' do
- it 'presents the issue' do
- expect(subject[:text]).to match(issue.title)
- end
- end
-
- context 'multiple issues found' do
- let!(:issue2) { create(:issue, project: project, title: "someone find me") }
-
- it 'shows a link to the new issue' do
- expect(subject[:text]).to match(issue.title)
- expect(subject[:text]).to match(issue2.title)
- end
+ expect(subject[:text]).to start_with('Whoops! This action is not allowed')
end
end
@@ -90,7 +54,7 @@ describe Gitlab::ChatCommands::Command, service: true do
context 'and user can not create deployment' do
it 'returns action' do
expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to start_with('Whoops! That action is not allowed')
+ expect(subject[:text]).to start_with('Whoops! This action is not allowed')
end
end
@@ -100,7 +64,7 @@ describe Gitlab::ChatCommands::Command, service: true do
end
it 'returns action' do
- expect(subject[:text]).to include('Deployment from staging to production started.')
+ expect(subject[:text]).to include('Deployment started from staging to production')
expect(subject[:response_type]).to be(:in_channel)
end
diff --git a/spec/lib/gitlab/chat_commands/deploy_spec.rb b/spec/lib/gitlab/chat_commands/deploy_spec.rb
index bd8099c92da..b3358a32161 100644
--- a/spec/lib/gitlab/chat_commands/deploy_spec.rb
+++ b/spec/lib/gitlab/chat_commands/deploy_spec.rb
@@ -15,8 +15,9 @@ describe Gitlab::ChatCommands::Deploy, service: true do
end
context 'if no environment is defined' do
- it 'returns nil' do
- expect(subject).to be_nil
+ it 'does not execute an action' do
+ expect(subject[:response_type]).to be(:ephemeral)
+ expect(subject[:text]).to eq("No action found to be executed")
end
end
@@ -26,8 +27,9 @@ describe Gitlab::ChatCommands::Deploy, service: true do
let!(:deployment) { create(:deployment, environment: staging, deployable: build) }
context 'without actions' do
- it 'returns nil' do
- expect(subject).to be_nil
+ it 'does not execute an action' do
+ expect(subject[:response_type]).to be(:ephemeral)
+ expect(subject[:text]).to eq("No action found to be executed")
end
end
@@ -37,8 +39,8 @@ describe Gitlab::ChatCommands::Deploy, service: true do
end
it 'returns success result' do
- expect(subject.type).to eq(:success)
- expect(subject.message).to include('Deployment from staging to production started')
+ expect(subject[:response_type]).to be(:in_channel)
+ expect(subject[:text]).to start_with('Deployment started from staging to production')
end
context 'when duplicate action exists' do
@@ -47,8 +49,8 @@ describe Gitlab::ChatCommands::Deploy, service: true do
end
it 'returns error' do
- expect(subject.type).to eq(:error)
- expect(subject.message).to include('Too many actions defined')
+ expect(subject[:response_type]).to be(:ephemeral)
+ expect(subject[:text]).to eq('Too many actions defined')
end
end
@@ -59,9 +61,9 @@ describe Gitlab::ChatCommands::Deploy, service: true do
name: 'teardown', environment: 'production')
end
- it 'returns success result' do
- expect(subject.type).to eq(:success)
- expect(subject.message).to include('Deployment from staging to production started')
+ it 'returns the success message' do
+ expect(subject[:response_type]).to be(:in_channel)
+ expect(subject[:text]).to start_with('Deployment started from staging to production')
end
end
end
diff --git a/spec/lib/gitlab/chat_commands/issue_create_spec.rb b/spec/lib/gitlab/chat_commands/issue_create_spec.rb
index 6c71e79ff6d..0f84b19a5a4 100644
--- a/spec/lib/gitlab/chat_commands/issue_create_spec.rb
+++ b/spec/lib/gitlab/chat_commands/issue_create_spec.rb
@@ -18,7 +18,7 @@ describe Gitlab::ChatCommands::IssueCreate, service: true do
it 'creates the issue' do
expect { subject }.to change { project.issues.count }.by(1)
- expect(subject.title).to eq('bird is the word')
+ expect(subject[:response_type]).to be(:in_channel)
end
end
@@ -41,6 +41,16 @@ describe Gitlab::ChatCommands::IssueCreate, service: true do
expect { subject }.to change { project.issues.count }.by(1)
end
end
+
+ context 'issue cannot be created' do
+ let!(:issue) { create(:issue, project: project, title: 'bird is the word') }
+ let(:regex_match) { described_class.match("issue create #{'a' * 512}}") }
+
+ it 'displays the errors' do
+ expect(subject[:response_type]).to be(:ephemeral)
+ expect(subject[:text]).to match("- Title is too long")
+ end
+ end
end
describe '.match' do
diff --git a/spec/lib/gitlab/chat_commands/issue_search_spec.rb b/spec/lib/gitlab/chat_commands/issue_search_spec.rb
index 24c06a967fa..04d10ad52a1 100644
--- a/spec/lib/gitlab/chat_commands/issue_search_spec.rb
+++ b/spec/lib/gitlab/chat_commands/issue_search_spec.rb
@@ -2,9 +2,9 @@ require 'spec_helper'
describe Gitlab::ChatCommands::IssueSearch, service: true do
describe '#execute' do
- let!(:issue) { create(:issue, title: 'find me') }
+ let!(:issue) { create(:issue, project: project, title: 'find me') }
let!(:confidential) { create(:issue, :confidential, project: project, title: 'mepmep find') }
- let(:project) { issue.project }
+ let(:project) { create(:empty_project) }
let(:user) { issue.author }
let(:regex_match) { described_class.match("issue search find") }
@@ -14,7 +14,8 @@ describe Gitlab::ChatCommands::IssueSearch, service: true do
context 'when the user has no access' do
it 'only returns the open issues' do
- expect(subject).not_to include(confidential)
+ expect(subject[:response_type]).to be(:ephemeral)
+ expect(subject[:text]).to match("not found")
end
end
@@ -24,13 +25,14 @@ describe Gitlab::ChatCommands::IssueSearch, service: true do
end
it 'returns all results' do
- expect(subject).to include(confidential, issue)
+ expect(subject).to have_key(:attachments)
+ expect(subject[:text]).to match("Here are the issues I found:")
end
end
context 'without hits on the query' do
it 'returns an empty collection' do
- expect(subject).to be_empty
+ expect(subject[:text]).to match("not found")
end
end
end
diff --git a/spec/lib/gitlab/chat_commands/issue_show_spec.rb b/spec/lib/gitlab/chat_commands/issue_show_spec.rb
index 2eab73e49e5..89932c395c6 100644
--- a/spec/lib/gitlab/chat_commands/issue_show_spec.rb
+++ b/spec/lib/gitlab/chat_commands/issue_show_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper'
describe Gitlab::ChatCommands::IssueShow, service: true do
describe '#execute' do
- let(:issue) { create(:issue) }
- let(:project) { issue.project }
+ let(:issue) { create(:issue, project: project) }
+ let(:project) { create(:empty_project) }
let(:user) { issue.author }
let(:regex_match) { described_class.match("issue show #{issue.iid}") }
@@ -16,15 +16,19 @@ describe Gitlab::ChatCommands::IssueShow, service: true do
end
context 'the issue exists' do
+ let(:title) { subject[:attachments].first[:title] }
+
it 'returns the issue' do
- expect(subject.iid).to be issue.iid
+ expect(subject[:response_type]).to be(:in_channel)
+ expect(title).to eq(issue.title)
end
context 'when its reference is given' do
let(:regex_match) { described_class.match("issue show #{issue.to_reference}") }
it 'shows the issue' do
- expect(subject.iid).to be issue.iid
+ expect(subject[:response_type]).to be(:in_channel)
+ expect(title).to eq(issue.title)
end
end
end
@@ -32,17 +36,24 @@ describe Gitlab::ChatCommands::IssueShow, service: true do
context 'the issue does not exist' do
let(:regex_match) { described_class.match("issue show 2343242") }
- it "returns nil" do
- expect(subject).to be_nil
+ it "returns not found" do
+ expect(subject[:response_type]).to be(:ephemeral)
+ expect(subject[:text]).to match("not found")
end
end
end
- describe 'self.match' do
+ describe '.match' do
it 'matches the iid' do
match = described_class.match("issue show 123")
expect(match[:iid]).to eq("123")
end
+
+ it 'accepts a reference' do
+ match = described_class.match("issue show #{Issue.reference_prefix}123")
+
+ expect(match[:iid]).to eq("123")
+ end
end
end
diff --git a/spec/lib/gitlab/chat_commands/presenters/access_spec.rb b/spec/lib/gitlab/chat_commands/presenters/access_spec.rb
new file mode 100644
index 00000000000..ae41d75ab0c
--- /dev/null
+++ b/spec/lib/gitlab/chat_commands/presenters/access_spec.rb
@@ -0,0 +1,49 @@
+require 'spec_helper'
+
+describe Gitlab::ChatCommands::Presenters::Access do
+ describe '#access_denied' do
+ subject { described_class.new.access_denied }
+
+ it { is_expected.to be_a(Hash) }
+
+ it 'displays an error message' do
+ expect(subject[:text]).to match("is not allowed")
+ expect(subject[:response_type]).to be(:ephemeral)
+ end
+ end
+
+ describe '#not_found' do
+ subject { described_class.new.not_found }
+
+ it { is_expected.to be_a(Hash) }
+
+ it 'tells the user the resource was not found' do
+ expect(subject[:text]).to match("not found!")
+ expect(subject[:response_type]).to be(:ephemeral)
+ end
+ end
+
+ describe '#authorize' do
+ context 'with an authorization URL' do
+ subject { described_class.new('http://authorize.me').authorize }
+
+ it { is_expected.to be_a(Hash) }
+
+ it 'tells the user to authorize' do
+ expect(subject[:text]).to match("connect your GitLab account")
+ expect(subject[:response_type]).to be(:ephemeral)
+ end
+ end
+
+ context 'without authorization url' do
+ subject { described_class.new.authorize }
+
+ it { is_expected.to be_a(Hash) }
+
+ it 'tells the user to authorize' do
+ expect(subject[:text]).to match("Couldn't identify you")
+ expect(subject[:response_type]).to be(:ephemeral)
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/chat_commands/presenters/deploy_spec.rb b/spec/lib/gitlab/chat_commands/presenters/deploy_spec.rb
new file mode 100644
index 00000000000..1c48c727e30
--- /dev/null
+++ b/spec/lib/gitlab/chat_commands/presenters/deploy_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe Gitlab::ChatCommands::Presenters::Deploy do
+ let(:build) { create(:ci_build) }
+
+ describe '#present' do
+ subject { described_class.new(build).present('staging', 'prod') }
+
+ it { is_expected.to have_key(:text) }
+ it { is_expected.to have_key(:response_type) }
+ it { is_expected.to have_key(:status) }
+ it { is_expected.not_to have_key(:attachments) }
+
+ it 'messages the channel of the deploy' do
+ expect(subject[:response_type]).to be(:in_channel)
+ expect(subject[:text]).to start_with("Deployment started from staging to prod")
+ end
+ end
+
+ describe '#no_actions' do
+ subject { described_class.new(nil).no_actions }
+
+ it { is_expected.to have_key(:text) }
+ it { is_expected.to have_key(:response_type) }
+ it { is_expected.to have_key(:status) }
+ it { is_expected.not_to have_key(:attachments) }
+
+ it 'tells the user there is no action' do
+ expect(subject[:response_type]).to be(:ephemeral)
+ expect(subject[:text]).to eq("No action found to be executed")
+ end
+ end
+
+ describe '#too_many_actions' do
+ subject { described_class.new(nil).too_many_actions }
+
+ it { is_expected.to have_key(:text) }
+ it { is_expected.to have_key(:response_type) }
+ it { is_expected.to have_key(:status) }
+ it { is_expected.not_to have_key(:attachments) }
+
+ it 'tells the user there is no action' do
+ expect(subject[:response_type]).to be(:ephemeral)
+ expect(subject[:text]).to eq("Too many actions defined")
+ end
+ end
+end
diff --git a/spec/lib/gitlab/chat_commands/presenters/list_issues_spec.rb b/spec/lib/gitlab/chat_commands/presenters/list_issues_spec.rb
new file mode 100644
index 00000000000..1852395fc97
--- /dev/null
+++ b/spec/lib/gitlab/chat_commands/presenters/list_issues_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe Gitlab::ChatCommands::Presenters::ListIssues do
+ let(:project) { create(:empty_project) }
+ let(:message) { subject[:text] }
+ let(:issue) { project.issues.first }
+
+ before { create_list(:issue, 2, project: project) }
+
+ subject { described_class.new(project.issues).present }
+
+ it do
+ is_expected.to have_key(:text)
+ is_expected.to have_key(:status)
+ is_expected.to have_key(:response_type)
+ is_expected.to have_key(:attachments)
+ end
+
+ it 'shows a list of results' do
+ expect(subject[:response_type]).to be(:ephemeral)
+
+ expect(message).to start_with("Here are the issues I found")
+ end
+end
diff --git a/spec/lib/gitlab/chat_commands/presenters/show_issue_spec.rb b/spec/lib/gitlab/chat_commands/presenters/show_issue_spec.rb
new file mode 100644
index 00000000000..13a318fe680
--- /dev/null
+++ b/spec/lib/gitlab/chat_commands/presenters/show_issue_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe Gitlab::ChatCommands::Presenters::ShowIssue do
+ let(:project) { create(:empty_project) }
+ let(:issue) { create(:issue, project: project) }
+ let(:attachment) { subject[:attachments].first }
+
+ subject { described_class.new(issue).present }
+
+ it { is_expected.to be_a(Hash) }
+
+ it 'shows the issue' do
+ expect(subject[:response_type]).to be(:in_channel)
+ expect(subject).to have_key(:attachments)
+ expect(attachment[:title]).to eq(issue.title)
+ end
+
+ context 'with upvotes' do
+ before do
+ create(:award_emoji, :upvote, awardable: issue)
+ end
+
+ it 'shows the upvote count' do
+ expect(attachment[:text]).to start_with(":+1: 1")
+ end
+ end
+end
diff --git a/spec/lib/mattermost/client_spec.rb b/spec/lib/mattermost/client_spec.rb
deleted file mode 100644
index dc11a414717..00000000000
--- a/spec/lib/mattermost/client_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'spec_helper'
-
-describe Mattermost::Client do
- let(:user) { build(:user) }
-
- subject { described_class.new(user) }
-
- context 'JSON parse error' do
- before do
- Struct.new("Request", :body, :success?)
- end
-
- it 'yields an error on malformed JSON' do
- bad_json = Struct::Request.new("I'm not json", true)
- expect { subject.send(:json_response, bad_json) }.to raise_error(Mattermost::ClientError)
- end
-
- it 'shows a client error if the request was unsuccessful' do
- bad_request = Struct::Request.new("true", false)
-
- expect { subject.send(:json_response, bad_request) }.to raise_error(Mattermost::ClientError)
- end
- end
-end
diff --git a/spec/lib/mattermost/command_spec.rb b/spec/lib/mattermost/command_spec.rb
deleted file mode 100644
index 5ccf1100898..00000000000
--- a/spec/lib/mattermost/command_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require 'spec_helper'
-
-describe Mattermost::Command do
- let(:params) { { 'token' => 'token', team_id: 'abc' } }
-
- before do
- Mattermost::Session.base_uri('http://mattermost.example.com')
-
- allow_any_instance_of(Mattermost::Client).to receive(:with_session).
- and_yield(Mattermost::Session.new(nil))
- end
-
- describe '#create' do
- let(:params) do
- { team_id: 'abc',
- trigger: 'gitlab'
- }
- end
-
- subject { described_class.new(nil).create(params) }
-
- context 'for valid trigger word' do
- before do
- stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create').
- with(body: {
- team_id: 'abc',
- trigger: 'gitlab' }.to_json).
- to_return(
- status: 200,
- headers: { 'Content-Type' => 'application/json' },
- body: { token: 'token' }.to_json
- )
- end
-
- it 'returns a token' do
- is_expected.to eq('token')
- end
- end
-
- context 'for error message' do
- before do
- stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create').
- to_return(
- status: 500,
- headers: { 'Content-Type' => 'application/json' },
- body: {
- id: 'api.command.duplicate_trigger.app_error',
- message: 'This trigger word is already in use. Please choose another word.',
- detailed_error: '',
- request_id: 'obc374man7bx5r3dbc1q5qhf3r',
- status_code: 500
- }.to_json
- )
- end
-
- it 'raises an error with message' do
- expect { subject }.to raise_error(Mattermost::Error, 'This trigger word is already in use. Please choose another word.')
- end
- end
- end
-end
diff --git a/spec/lib/mattermost/session_spec.rb b/spec/lib/mattermost/session_spec.rb
deleted file mode 100644
index 74d12e37181..00000000000
--- a/spec/lib/mattermost/session_spec.rb
+++ /dev/null
@@ -1,123 +0,0 @@
-require 'spec_helper'
-
-describe Mattermost::Session, type: :request do
- let(:user) { create(:user) }
-
- let(:gitlab_url) { "http://gitlab.com" }
- let(:mattermost_url) { "http://mattermost.com" }
-
- subject { described_class.new(user) }
-
- # Needed for doorkeeper to function
- it { is_expected.to respond_to(:current_resource_owner) }
- it { is_expected.to respond_to(:request) }
- it { is_expected.to respond_to(:authorization) }
- it { is_expected.to respond_to(:strategy) }
-
- before do
- described_class.base_uri(mattermost_url)
- end
-
- describe '#with session' do
- let(:location) { 'http://location.tld' }
- let!(:stub) do
- WebMock.stub_request(:get, "#{mattermost_url}/api/v3/oauth/gitlab/login").
- to_return(headers: { 'location' => location }, status: 307)
- end
-
- context 'without oauth uri' do
- it 'makes a request to the oauth uri' do
- expect { subject.with_session }.to raise_error(Mattermost::NoSessionError)
- end
- end
-
- context 'with oauth_uri' do
- let!(:doorkeeper) do
- Doorkeeper::Application.create(
- name: "GitLab Mattermost",
- redirect_uri: "#{mattermost_url}/signup/gitlab/complete\n#{mattermost_url}/login/gitlab/complete",
- scopes: "")
- end
-
- context 'without token_uri' do
- it 'can not create a session' do
- expect do
- subject.with_session
- end.to raise_error(Mattermost::NoSessionError)
- end
- end
-
- context 'with token_uri' do
- let(:state) { "state" }
- let(:params) do
- { response_type: "code",
- client_id: doorkeeper.uid,
- redirect_uri: "#{mattermost_url}/signup/gitlab/complete",
- state: state }
- end
- let(:location) do
- "#{gitlab_url}/oauth/authorize?#{URI.encode_www_form(params)}"
- end
-
- before do
- WebMock.stub_request(:get, "#{mattermost_url}/signup/gitlab/complete").
- with(query: hash_including({ 'state' => state })).
- to_return do |request|
- post "/oauth/token",
- client_id: doorkeeper.uid,
- client_secret: doorkeeper.secret,
- redirect_uri: params[:redirect_uri],
- grant_type: 'authorization_code',
- code: request.uri.query_values['code']
-
- if response.status == 200
- { headers: { 'token' => 'thisworksnow' }, status: 202 }
- end
- end
-
- WebMock.stub_request(:post, "#{mattermost_url}/api/v3/users/logout").
- to_return(headers: { Authorization: 'token thisworksnow' }, status: 200)
- end
-
- it 'can setup a session' do
- subject.with_session do |session|
- end
-
- expect(subject.token).not_to be_nil
- end
-
- it 'returns the value of the block' do
- result = subject.with_session do |session|
- "value"
- end
-
- expect(result).to eq("value")
- end
- end
- end
-
- context 'with lease' do
- before do
- allow(subject).to receive(:lease_try_obtain).and_return('aldkfjsldfk')
- end
-
- it 'tries to obtain a lease' do
- expect(subject).to receive(:lease_try_obtain)
- expect(Gitlab::ExclusiveLease).to receive(:cancel)
-
- # Cannot setup a session, but we should still cancel the lease
- expect { subject.with_session }.to raise_error(Mattermost::NoSessionError)
- end
- end
-
- context 'without lease' do
- before do
- allow(subject).to receive(:lease_try_obtain).and_return(nil)
- end
-
- it 'returns a NoSessionError error' do
- expect { subject.with_session }.to raise_error(Mattermost::NoSessionError)
- end
- end
- end
-end
diff --git a/spec/lib/mattermost/team_spec.rb b/spec/lib/mattermost/team_spec.rb
deleted file mode 100644
index 2d14be6bcc2..00000000000
--- a/spec/lib/mattermost/team_spec.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-require 'spec_helper'
-
-describe Mattermost::Team do
- before do
- Mattermost::Session.base_uri('http://mattermost.example.com')
-
- allow_any_instance_of(Mattermost::Client).to receive(:with_session).
- and_yield(Mattermost::Session.new(nil))
- end
-
- describe '#all' do
- subject { described_class.new(nil).all }
-
- context 'for valid request' do
- let(:response) do
- [{
- "id" => "xiyro8huptfhdndadpz8r3wnbo",
- "create_at" => 1482174222155,
- "update_at" => 1482174222155,
- "delete_at" => 0,
- "display_name" => "chatops",
- "name" => "chatops",
- "email" => "admin@example.com",
- "type" => "O",
- "company_name" => "",
- "allowed_domains" => "",
- "invite_id" => "o4utakb9jtb7imctdfzbf9r5ro",
- "allow_open_invite" => false }]
- end
-
- before do
- stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all').
- to_return(
- status: 200,
- headers: { 'Content-Type' => 'application/json' },
- body: response.to_json
- )
- end
-
- it 'returns a token' do
- is_expected.to eq(response)
- end
- end
-
- context 'for error message' do
- before do
- stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all').
- to_return(
- status: 500,
- headers: { 'Content-Type' => 'application/json' },
- body: {
- id: 'api.team.list.app_error',
- message: 'Cannot list teams.',
- detailed_error: '',
- request_id: 'obc374man7bx5r3dbc1q5qhf3r',
- status_code: 500
- }.to_json
- )
- end
-
- it 'raises an error with message' do
- expect { subject }.to raise_error(Mattermost::Error, 'Cannot list teams.')
- end
- end
- end
-end