summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2016-11-17 15:30:04 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-11-17 21:34:24 +0100
commit1607efa40081702488e22e560db2c1e30cd80093 (patch)
treee43388424e05c45eee6cf2ddef9f7e538327019b /spec/lib
parent6737ada0c8d980ed1bd8f425e885fa1b89930616 (diff)
downloadgitlab-ce-1607efa40081702488e22e560db2c1e30cd80093.tar.gz
Add tests for increased converage
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/chat_commands/command_spec.rb22
-rw-r--r--spec/lib/gitlab/chat_commands/issue_create_spec.rb15
-rw-r--r--spec/lib/gitlab/chat_commands/issue_show_spec.rb8
3 files changed, 25 insertions, 20 deletions
diff --git a/spec/lib/gitlab/chat_commands/command_spec.rb b/spec/lib/gitlab/chat_commands/command_spec.rb
index bbd47f45761..328187b5048 100644
--- a/spec/lib/gitlab/chat_commands/command_spec.rb
+++ b/spec/lib/gitlab/chat_commands/command_spec.rb
@@ -1,19 +1,19 @@
require 'spec_helper'
describe Gitlab::ChatCommands::Command, service: true do
- let(:project) { create(:project) }
- let(:user) { create(:user) }
- let(:params) { { text: 'issue show 1' } }
+ let(:project) { create(:project) }
+ let(:user) { create(:user) }
subject { described_class.new(project, user, params).execute }
describe '#execute' do
- context 'when the command is not available' do
+ context 'when no command is not available' do
+ let(:params) { { text: 'issue show 1' } }
let(:project) { create(:project, has_external_issue_tracker: true) }
it 'displays the help message' do
expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to start_with('Available commands')
+ expect(subject[:text]).to start_with('404 not found')
end
end
@@ -25,5 +25,17 @@ describe Gitlab::ChatCommands::Command, service: true do
expect(subject[:text]).to start_with('Available commands')
end
end
+
+ context 'issue is succesfully 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
+ 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 5f5cc706c96..4831f24efed 100644
--- a/spec/lib/gitlab/chat_commands/issue_create_spec.rb
+++ b/spec/lib/gitlab/chat_commands/issue_create_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper'
describe Gitlab::ChatCommands::IssueCreate, service: true do
describe '#execute' do
- let(:project) { create(:empty_project) }
- let(:user) { create(:user) }
+ let(:project) { create(:empty_project) }
+ let(:user) { create(:user) }
let(:regex_match) { described_class.match("issue create bird is the word") }
before do
@@ -16,12 +16,9 @@ describe Gitlab::ChatCommands::IssueCreate, service: true do
context 'without description' do
it 'creates the issue' do
- expect do
- subject # this trigger the execution
- end.to change { project.issues.count }.by(1)
+ expect { subject }.to change { project.issues.count }.by(1)
- expect(subject[:response_type]).to be :in_channel
- expect(subject[:text]).to match('bird is the word')
+ expect(subject.title).to eq('bird is the word')
end
end
@@ -29,11 +26,9 @@ describe Gitlab::ChatCommands::IssueCreate, service: true do
let(:description) { "Surfin bird" }
let(:regex_match) { described_class.match("issue create bird is the word\n#{description}") }
- before do
+ it 'creates the issue with description' do
subject
- end
- it 'creates the issue with description' do
expect(Issue.last.description).to eq(description)
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 d7824dd6bf5..331a4604e9b 100644
--- a/spec/lib/gitlab/chat_commands/issue_show_spec.rb
+++ b/spec/lib/gitlab/chat_commands/issue_show_spec.rb
@@ -17,17 +17,15 @@ describe Gitlab::ChatCommands::IssueShow, service: true do
context 'the issue exists' do
it 'returns the issue' do
- expect(subject[:response_type]).to be(:in_channel)
- expect(subject[:text]).to match(issue.title)
+ expect(subject.iid).to be issue.iid
end
end
context 'the issue does not exist' do
- let(:regex_match) { described_class.match("issue show 1234") }
+ let(:regex_match) { described_class.match("issue show 2343242") }
it "returns nil" do
- expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to start_with('404 not found!')
+ expect(subject).to be_nil
end
end
end