Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix some issues and now the tests pass! HUZZAH!

  • Loading branch information...
commit 22538f2a18fc8de5661b6caa218242a7f2d256c8 1 parent 296d67b
@joshk joshk authored
View
6 lib/travis/hub/handler/request.rb
@@ -6,14 +6,14 @@ class Handler
class Request < Handler
def handle
if authenticated?
- Request.create_from(scm_payload, token)
+ ::Request.create_from(scm_payload, token)
end
end
protected
def authenticated?
- Token.find_by_token(token).user.login == login
+ ::Token.find_by_token(token).user.login == login
end
def login
@@ -25,7 +25,7 @@ def token
end
def scm_payload
- MultiJson.decode(payload[:credentials][:request])
+ MultiJson.decode(payload[:request])
end
end
end
View
12 spec/travis/hub/handler/request_spec.rb
@@ -3,6 +3,7 @@
describe Travis::Hub::Handler::Request do
let(:handler) { Travis::Hub::Handler::Request.new(:request, Hashr.new(payload)) }
let(:user) { stub('user', :login => 'user') }
+ let(:token) { stub('token', :user => user) }
let(:payload) do
{
:credentials => {
@@ -12,12 +13,13 @@
:request => GITHUB_PAYLOADS['gem-release']
}
end
+ let(:github_request) { MultiJson.decode(payload[:request]) }
describe '#handle' do
describe 'authorized' do
before do
- Request.stubs(:create_from).with(payload, '12345').returns(true)
- Token.stubs(:find_by_token).with('12345').returns(user)
+ Request.stubs(:create_from).with(github_request, '12345').returns(true)
+ Token.stubs(:find_by_token).with('12345').returns(token)
end
it "creates a valid request" do
@@ -26,13 +28,15 @@
end
describe 'not authorized' do
- let(:another_user) { stub('user_two', :login => 'user2') }
+ let(:user) { stub('user_two', :login => 'user2') }
+ let(:token) { stub('token', :user => user) }
before do
- Token.stubs(:find_by_token).with('12345').returns(another_user)
+ Token.stubs(:find_by_token).with('12345').returns(token)
end
it "rejects the request" do
+ Request.expects(:create_from).never
handler.handle
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.