Skip to content
Snippets Groups Projects
Commit 90029a5c authored by Mike Wyatt's avatar Mike Wyatt
Browse files

Actually test the posted comment in Asana service

parent 9e7a88f0
No related branches found
No related tags found
2 merge requests!2302Better support for referencing and closing issues in asana_service.rb (by @mikew1),!2111Better support for referencing and closing issues in asana_service.rb
Loading
@@ -40,6 +40,20 @@ describe AsanaService, models: true do
Loading
@@ -40,6 +40,20 @@ describe AsanaService, models: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
   
def create_data_for_commits(*messages)
data = {
object_kind: 'push',
ref: 'master',
user_name: user.name,
commits: messages.map do |m|
{
message: m,
url: 'https://gitlab.com/',
}
end
}
end
before do before do
@asana = AsanaService.new @asana = AsanaService.new
allow(@asana).to receive_messages( allow(@asana).to receive_messages(
Loading
@@ -51,12 +65,15 @@ describe AsanaService, models: true do
Loading
@@ -51,12 +65,15 @@ describe AsanaService, models: true do
) )
end end
   
it 'should call Asana service to created a story' do it 'should call Asana service to create a story' do
d1 = double('Asana::Task', add_comment: true) data = create_data_for_commits('Message from commit. related to #123456')
expect(d1).to receive(:add_comment) expected_message = "#{data[:user_name]} pushed to branch #{data[:ref]} of #{project.name_with_namespace} ( #{data[:commits][0][:url]} ): #{data[:commits][0][:message]}"
d1 = double('Asana::Task')
expect(d1).to receive(:add_comment).with(text: expected_message)
expect(Asana::Task).to receive(:find_by_id).with(anything, '123456').once.and_return(d1) expect(Asana::Task).to receive(:find_by_id).with(anything, '123456').once.and_return(d1)
   
@asana.check_commit('related to #123456', 'pushed') @asana.execute(data)
end end
   
it 'should call Asana service to created a story and close a task' do it 'should call Asana service to created a story and close a task' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment