github_concern 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.markdown +78 -0
  3. data/Rakefile +23 -0
  4. data/app/assets/javascripts/github.js +2 -0
  5. data/app/assets/stylesheets/github.css +4 -0
  6. data/app/controllers/application_controller.rb +2 -0
  7. data/app/controllers/github_controller.rb +7 -0
  8. data/app/helpers/github_helper.rb +2 -0
  9. data/app/models/git_commit.rb +4 -0
  10. data/app/models/git_push.rb +56 -0
  11. data/app/models/github_concernable_git_push.rb +4 -0
  12. data/config/routes.rb +3 -0
  13. data/db/migrate/20111204031658_create_git_pushes.rb +9 -0
  14. data/db/migrate/20111204031730_create_git_commits.rb +10 -0
  15. data/db/migrate/20111204041743_add_user_id_to_git_push.rb +5 -0
  16. data/db/migrate/20111204055027_create_github_concernable_git_pushes.rb +11 -0
  17. data/lib/github_concern/engine.rb +50 -0
  18. data/lib/github_concern/version.rb +3 -0
  19. data/lib/github_concern.rb +15 -0
  20. data/lib/tasks/github_concern_tasks.rake +4 -0
  21. data/spec/controllers/github_controller_spec.rb +29 -0
  22. data/spec/internal/app/models/project.rb +2 -0
  23. data/spec/internal/app/models/ticket.rb +6 -0
  24. data/spec/internal/app/models/user.rb +2 -0
  25. data/spec/internal/config/application.rb +1 -0
  26. data/spec/internal/config/database.yml +3 -0
  27. data/spec/internal/config/initializers/github_concern.rb +11 -0
  28. data/spec/internal/config/routes.rb +3 -0
  29. data/spec/internal/db/combustion_test.sqlite +0 -0
  30. data/spec/internal/db/schema.rb +36 -0
  31. data/spec/internal/log/test.log +2387 -0
  32. data/spec/internal/public/favicon.ico +0 -0
  33. data/spec/models/git_push.rb +57 -0
  34. data/spec/spec_helper.rb +13 -0
  35. data/spec/support/github_payload.rb +3 -0
  36. metadata +158 -0
File without changes
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe GitPush do
4
+ describe "when I create a new git push" do
5
+ before(:all) do
6
+ Project.class_eval {github_concern :repo => :github_repo }
7
+ Ticket.class_eval {github_concern :repo => :github_repo, :branch => :github_branch }
8
+
9
+ @project = Project.create(:github_repo => "some_repo")
10
+ @non_concerned_project = Project.create()
11
+
12
+ @ticket = Ticket.create(:github_repo => "some_repo", :github_branch => "testing")
13
+ @unconcerned_ticket = Ticket.create(:github_repo => "some_other_repo", :github_branch => "testing")
14
+ @unconcerned_ticket_2 = Ticket.create(:github_repo => "some_repo", :github_branch => "testing_2")
15
+
16
+ @user = User.create(:email => "test@test.com")
17
+ @non_concerned_user = User.create
18
+ @git_push = GitPush.create(:payload => valid_payload_hash)
19
+ end
20
+
21
+ it "should serialize the payload" do
22
+ @git_push.reload
23
+ @git_push.payload.should == valid_payload_hash
24
+ end
25
+
26
+ it "should automatically concern the user who pushed" do
27
+ @user.git_pushes.include?(@git_push).should == true
28
+ end
29
+
30
+ it "should not concern the users who dont care" do
31
+ @non_concerned_user.git_pushes.should == []
32
+ end
33
+
34
+ it "should automatically build commits" do
35
+ GitCommit.count.should == 1
36
+ @git_push.git_commits.should == [GitCommit.last]
37
+ @git_push.git_commits.last.payload.should == {"modified"=>["README"], "added"=>[], "timestamp"=>"2011-12-05T20:17:13-08:00", "removed"=>[], "author"=>{"name"=>"test_user", "username"=>"test_user", "email"=>"test@test.com"}, "url"=>"https://github.com/test_user/some_repo/commit/06e8f192e2e2c4c36f0759520e37cbcaea0cfb05", "id"=>"06e8f192e2e2c4c36f0759520e37cbcaea0cfb05", "distinct"=>true, "message"=>"readme"}
38
+ end
39
+
40
+ it "should automatically concern the project" do
41
+ @project.git_pushes.include?(@git_push).should == true
42
+ end
43
+
44
+ it "should not concern projects that dont care" do
45
+ @non_concerned_project.git_pushes.should == []
46
+ end
47
+
48
+ it "should concern tickets that care" do
49
+ @ticket.git_pushes.include?(@git_push).should == true
50
+ end
51
+
52
+ it "should not concern tickets that don't care" do
53
+ @unconcerned_ticket.git_pushes.should == []
54
+ @unconcerned_ticket_2.git_pushes.should == []
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'support/github_payload.rb'
4
+
5
+ Bundler.require :default, :development
6
+
7
+ Combustion.initialize!
8
+
9
+ require 'rspec/rails'
10
+
11
+ RSpec.configure do |config|
12
+ config.use_transactional_fixtures = true
13
+ end
@@ -0,0 +1,3 @@
1
+ def valid_payload_hash
2
+ {"pusher"=>{"name"=>"test_user", "email"=>"test@test.com"}, "repository"=>{"name"=>"some_repo", "size"=>15488, "has_wiki"=>true, "created_at"=>"2011/11/24 21:24:54 -0800", "private"=>false, "watchers"=>1, "fork"=>false, "url"=>"https://github.com/test_user/some_repo", "language"=>"Ruby", "pushed_at"=>"2011/12/05 20:17:17 -0800", "has_downloads"=>true, "open_issues"=>0, "has_issues"=>true, "homepage"=>"", "description"=>"", "forks"=>1, "owner"=>{"name"=>"test_user", "email"=>"test@test.com"}}, "forced"=>false, "after"=>"06e8f192e2e2c4c36f0759520e37cbcaea0cfb05", "deleted"=>false, "ref"=>"refs/heads/testing", "commits"=>[{"modified"=>["README"], "added"=>[], "timestamp"=>"2011-12-05T20:17:13-08:00", "removed"=>[], "author"=>{"name"=>"test_user", "username"=>"test_user", "email"=>"test@test.com"}, "url"=>"https://github.com/test_user/some_repo/commit/06e8f192e2e2c4c36f0759520e37cbcaea0cfb05", "id"=>"06e8f192e2e2c4c36f0759520e37cbcaea0cfb05", "distinct"=>true, "message"=>"readme"}], "compare"=>"https://github.com/test_user/some_repo/compare/bcd84c3...06e8f19", "before"=>"bcd84c38982232c0242539e41799a7826bd162ae", "created"=>false}
3
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_concern
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Gamble
9
+ - Josh Adams
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-12-19 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: &70298696195320 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 3.1.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70298696195320
26
+ - !ruby/object:Gem::Dependency
27
+ name: sqlite3
28
+ requirement: &70298696194560 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *70298696194560
37
+ - !ruby/object:Gem::Dependency
38
+ name: ruby-debug19
39
+ requirement: &70298696193780 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70298696193780
48
+ - !ruby/object:Gem::Dependency
49
+ name: combustion
50
+ requirement: &70298696192540 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 0.3.1
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *70298696192540
59
+ - !ruby/object:Gem::Dependency
60
+ name: rspec-rails
61
+ requirement: &70298696191420 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *70298696191420
70
+ description: Easily associate git commits with models
71
+ email:
72
+ - adamgamble@gmail.com
73
+ - josh@isotope11.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - app/assets/javascripts/github.js
79
+ - app/assets/stylesheets/github.css
80
+ - app/controllers/application_controller.rb
81
+ - app/controllers/github_controller.rb
82
+ - app/helpers/github_helper.rb
83
+ - app/models/git_commit.rb
84
+ - app/models/git_push.rb
85
+ - app/models/github_concernable_git_push.rb
86
+ - config/routes.rb
87
+ - db/migrate/20111204031658_create_git_pushes.rb
88
+ - db/migrate/20111204031730_create_git_commits.rb
89
+ - db/migrate/20111204041743_add_user_id_to_git_push.rb
90
+ - db/migrate/20111204055027_create_github_concernable_git_pushes.rb
91
+ - lib/github_concern/engine.rb
92
+ - lib/github_concern/version.rb
93
+ - lib/github_concern.rb
94
+ - lib/tasks/github_concern_tasks.rake
95
+ - MIT-LICENSE
96
+ - Rakefile
97
+ - README.markdown
98
+ - spec/controllers/github_controller_spec.rb
99
+ - spec/internal/app/models/project.rb
100
+ - spec/internal/app/models/ticket.rb
101
+ - spec/internal/app/models/user.rb
102
+ - spec/internal/config/application.rb
103
+ - spec/internal/config/database.yml
104
+ - spec/internal/config/initializers/github_concern.rb
105
+ - spec/internal/config/routes.rb
106
+ - spec/internal/db/combustion_test.sqlite
107
+ - spec/internal/db/schema.rb
108
+ - spec/internal/log/test.log
109
+ - spec/internal/public/favicon.ico
110
+ - spec/models/git_push.rb
111
+ - spec/spec_helper.rb
112
+ - spec/support/github_payload.rb
113
+ homepage: http://www.github.com/adamgamble/github_concern
114
+ licenses: []
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ segments:
126
+ - 0
127
+ hash: 2234518977103031758
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ segments:
135
+ - 0
136
+ hash: 2234518977103031758
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.10
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Easily associate git commits with models
143
+ test_files:
144
+ - spec/controllers/github_controller_spec.rb
145
+ - spec/internal/app/models/project.rb
146
+ - spec/internal/app/models/ticket.rb
147
+ - spec/internal/app/models/user.rb
148
+ - spec/internal/config/application.rb
149
+ - spec/internal/config/database.yml
150
+ - spec/internal/config/initializers/github_concern.rb
151
+ - spec/internal/config/routes.rb
152
+ - spec/internal/db/combustion_test.sqlite
153
+ - spec/internal/db/schema.rb
154
+ - spec/internal/log/test.log
155
+ - spec/internal/public/favicon.ico
156
+ - spec/models/git_push.rb
157
+ - spec/spec_helper.rb
158
+ - spec/support/github_payload.rb