OSDN Git Service

Make changes to tests
[wvm/gitlab.git] / spec / models / flowdock_service_spec.rb
1 # == Schema Information
2 #
3 # Table name: services
4 #
5 #  id          :integer          not null, primary key
6 #  type        :string(255)
7 #  title       :string(255)
8 #  token       :string(255)
9 #  project_id  :integer          not null
10 #  created_at  :datetime         not null
11 #  updated_at  :datetime         not null
12 #  active      :boolean          default(FALSE), not null
13 #  project_url :string(255)
14 #  subdomain   :string(255)
15 #  room        :string(255)
16 #
17
18 require 'spec_helper'
19
20 describe FlowdockService do
21   describe "Associations" do
22     it { should belong_to :project }
23     it { should have_one :service_hook }
24   end
25
26   describe "Execute" do
27     let(:user)    { create(:user) }
28     let(:project) { create(:project) }
29
30     before do
31       @flowdock_service = FlowdockService.new
32       @flowdock_service.stub(
33         project_id: project.id,
34         project: project,
35         service_hook: true,
36         token: 'verySecret'
37       )
38       @sample_data = GitPushService.new.sample_data(project, user)
39       @api_url = 'https://api.flowdock.com/v1/git/verySecret'
40       WebMock.stub_request(:post, @api_url)
41     end
42
43     it "should call FlowDock API" do
44       @flowdock_service.execute(@sample_data)
45       WebMock.should have_requested(:post, @api_url).with(
46         body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
47       ).once
48     end
49   end
50 end