Sha256: cdda01558ff6a453ae839539a62aac26a50357a06013075bb070cec7deb59091

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'
require 'support/active_record'

describe Repository, 'service_hook' do
  include Support::ActiveRecord

  describe 'set' do
    let(:user)       { stub('user', :login => 'login', :github_oauth_token => 'oauth_token', :tokens => [stub(:token => 'user_token')]) }
    let(:repository) { Factory(:repository, :owner_name => 'svenfuchs', :name => 'minimal') }

    it 'given true it activates a service hook' do
      Travis.config.stubs(:domain).returns('test.travis-ci.org')
      Travis::GithubApi.expects(:add_service_hook).with('svenfuchs', 'minimal', 'oauth_token',
        :user   => 'login',
        :token  => 'user_token',
        :domain => 'test.travis-ci.org'
      )

      repository.service_hook.set(true, user)
      repository.should be_persisted
      repository.should be_active
    end

    it 'given false it removes a service hook' do
      Travis::GithubApi.expects(:remove_service_hook).with('svenfuchs', 'minimal', 'oauth_token')

      repository.service_hook.set(false, user)
      repository.should be_persisted
      repository.should_not be_active
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis-core-0.0.1 spec/travis/model/repository/service_hook_spec.rb