Skip to content

Commit

Permalink
Remove number from on_pull_request arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-rushakoff committed Oct 4, 2013
1 parent cd11b2c commit 7482ce9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class MyApp < RightHook::App
# Code to execute for GitHub's pull request hook.
# The secret has already been verified if your code is being called.
# See app.rb and spec/app/*_spec.rb for signatures and examples of the valid handlers.
def on_pull_request(owner, repo_name, action, number, pull_request_json)
def on_pull_request(owner, repo_name, action, pull_request_json)
message = <<-MSG
GitHub user #{pull_request_json['user']['login']} has opened pull request ##{number}
GitHub user #{pull_request_json['user']['login']} has opened pull request ##{pull_request_json['number']}
on repository #{owner}/#{repo_name}!
MSG
send_text_message(MY_PHONE_NUMBER, message) # or whatever you want
Expand Down Expand Up @@ -113,7 +113,7 @@ subscriber = RightHook::Subscriber.new(default_opts)
subscriber.subscribe(
owner: 'octocat',
repo_name: 'Hello-World',
event_type: 'pull_request',
event_type: RightHook::Event::PULL_REQUEST,
secret: 'secret_for_hello_world'
)
```
Expand Down
2 changes: 1 addition & 1 deletion lib/right_hook/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class App < Sinatra::Base
json = JSON.parse(params['payload'])
case event_type
when Event::PULL_REQUEST
on_pull_request(owner, repo_name, json['number'], json['action'], json['pull_request'])
on_pull_request(owner, repo_name, json['action'], json['pull_request'])
when Event::ISSUE
on_issue(owner, repo_name, json['action'], json['issue'])
else
Expand Down
8 changes: 3 additions & 5 deletions spec/app/pull_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
describe 'Pull requests' do
class PullRequestApp < RightHook::App
class << self
attr_accessor :owner, :repo_name, :action, :number, :pull_request_json
attr_accessor :owner, :repo_name, :action, :pull_request_json
end

def on_pull_request(owner, repo_name, number, action, pull_request_json)
def on_pull_request(owner, repo_name, action, pull_request_json)
self.class.owner = owner
self.class.repo_name = repo_name
self.class.action = action
self.class.number = number
self.class.pull_request_json = pull_request_json
end

Expand All @@ -25,7 +24,7 @@ def app
end

before do
app.owner = app.repo_name = app.action = app.number = app.pull_request_json = nil
app.owner = app.repo_name = app.action = app.pull_request_json = nil
end

it 'captures the interesting data' do
Expand All @@ -34,7 +33,6 @@ def app
expect(app.owner).to eq('mark-rushakoff')
expect(app.repo_name).to eq('right_hook')
expect(app.action).to eq('opened')
expect(app.number).to eq(1)

# if it has one key it probably has them all
expect(app.pull_request_json['body']).to eq('Please pull these awesome changes')
Expand Down

0 comments on commit 7482ce9

Please sign in to comment.