Skip to content

Commit

Permalink
handle strings or literals
Browse files Browse the repository at this point in the history
  • Loading branch information
rsanheim committed Sep 2, 2008
1 parent ecb2662 commit a4afac9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions lib/github_hook.rb
Expand Up @@ -3,7 +3,7 @@
require 'ostruct'

class GithubHook
VERSION = '0.6.2'
VERSION = '0.6.4'
attr_reader :before, :after, :ref, :repository, :owner, :commits

def initialize(json)
Expand All @@ -16,7 +16,7 @@ def initialize(json)
end

def parse_private_flag(private_flag)
private_flag == "true" ? true : false
private_flag.to_s == "true" ? true : false
end

def create_commits(payload)
Expand Down
11 changes: 7 additions & 4 deletions spec/github_hook_spec.rb
Expand Up @@ -83,15 +83,18 @@
end

describe "private project" do
before { @pc = GithubHook.new(PrivateProject)}

it "is private if private flag is false" do
it "is private if private flag is string true" do
@pc = GithubHook.new(PrivateProjectWithStringTrue)
@pc.repository.private.should == true
end

it "is private if private flag is literal true" do
@pc = GithubHook.new(PrivateProjectWithLiteralTrue)
@pc.repository.private.should == true
end

end



end

42 changes: 19 additions & 23 deletions spec/payload.rb
Expand Up @@ -74,7 +74,7 @@
}
EOL

PrivateProject = <<-EOL
PrivateProjectWithStringTrue = <<-EOL
{
"before": "5aef35982fb2d34e9d9d4502f6ede1072793222d",
"repository": {
Expand All @@ -86,29 +86,25 @@
"name": "defunkt"
}
},
"commits": [
{
"id": "41a212ee83ca127e3c8cf465891ab7216a705f59",
"url": "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
"author": {
"email": "chris@ozmm.org",
"name": "Chris Wanstrath"
},
"message": "okay i give in",
"timestamp": "2008-02-15T14:57:17-08:00",
"added": ["filepath.rb"]
},
{
"id": "de8251ff97ee194a289832576287d6f8ad74e3d0",
"url": "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
"author": {
"email": "chris@ozmm.org",
"name": "Chris Wanstrath"
},
"message": "update pricing a tad",
"timestamp": "2008-02-15T14:36:34-08:00"
"commits": [],
"after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
"ref": "refs/heads/master"
}
EOL

PrivateProjectWithLiteralTrue = <<-EOL
{
"before": "5aef35982fb2d34e9d9d4502f6ede1072793222d",
"repository": {
"url": "http://github.com/defunkt/github",
"name": "github",
"private": true,
"owner": {
"email": "chris@ozmm.org",
"name": "defunkt"
}
],
},
"commits": [],
"after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
"ref": "refs/heads/master"
}
Expand Down

0 comments on commit a4afac9

Please sign in to comment.