summaryrefslogtreecommitdiff
path: root/spec/requests/hooks_spec.rb
blob: 05432f13f3c8081856f2ba661173e3de6795b4d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'spec_helper'

describe "Hooks" do
  before do
    login_as :user
    @project = Factory :project
    @project.add_access(@user, :read, :admin)
  end

  describe "GET index" do
    it "should be available" do
      @hook = Factory :project_hook, :project => @project
      visit project_hooks_path(@project)
      page.should have_content "Hooks"
      page.should have_content @hook.url
    end
  end

  describe "New Hook" do
    before do
      @url = Faker::Internet.uri("http")
      visit project_hooks_path(@project)
      fill_in "hook_url", :with => @url
      expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1)
    end

    it "should open new team member popup" do
      page.current_path.should == project_hooks_path(@project)
      page.should have_content(@url)
    end
  end

  describe "Test" do
    before do
      @hook = Factory :project_hook, :project => @project
      stub_request(:post, @hook.url)
      visit project_hooks_path(@project)
      click_link "Test Hook"
    end

    it { page.current_path.should == project_hooks_path(@project) }
  end
end