hubstats 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.markdown +1 -0
  3. data/app/assets/javascripts/hubstats/users.js +5 -1
  4. data/app/controllers/hubstats/deploys_controller.rb +21 -8
  5. data/app/controllers/hubstats/pull_requests_controller.rb +2 -1
  6. data/app/controllers/hubstats/repos_controller.rb +13 -8
  7. data/app/controllers/hubstats/users_controller.rb +4 -5
  8. data/app/models/hubstats/deploy.rb +3 -3
  9. data/app/models/hubstats/pull_request.rb +12 -1
  10. data/app/models/hubstats/repo.rb +1 -0
  11. data/app/models/hubstats/user.rb +11 -1
  12. data/app/views/hubstats/deploys/index.html.erb +4 -4
  13. data/app/views/hubstats/deploys/show.html.erb +4 -0
  14. data/app/views/hubstats/partials/_deploy-condensed.html.erb +9 -4
  15. data/app/views/hubstats/partials/_deploy.html.erb +5 -5
  16. data/app/views/hubstats/partials/_quick_addition_stats.html.erb +19 -0
  17. data/app/views/hubstats/partials/_quick_stats.html.erb +19 -18
  18. data/app/views/hubstats/partials/_repo.html.erb +4 -3
  19. data/app/views/hubstats/partials/_user.html.erb +18 -5
  20. data/app/views/hubstats/pull_requests/show.html.erb +10 -0
  21. data/app/views/hubstats/repos/dashboard.html.erb +6 -11
  22. data/app/views/hubstats/repos/show.html.erb +20 -5
  23. data/app/views/hubstats/tables/_deploys-condensed.html.erb +2 -2
  24. data/app/views/hubstats/tables/_users-condensed.html.erb +1 -1
  25. data/app/views/hubstats/tables/_users.html.erb +9 -2
  26. data/app/views/hubstats/users/index.html.erb +1 -1
  27. data/app/views/hubstats/users/show.html.erb +9 -3
  28. data/config/routes.rb +1 -1
  29. data/db/migrate/20150526154850_create_hubstats_deploys.rb +0 -1
  30. data/db/migrate/20150605184015_add_user_id_delete_deployed_by_to_deploy.rb +6 -0
  31. data/db/migrate/20150605190549_add_merged_by_column_to_pull_request.rb +5 -0
  32. data/db/seeds.rb +1 -1
  33. data/lib/hubstats/version.rb +1 -1
  34. data/spec/controllers/hubstats/deploys_controller_spec.rb +36 -25
  35. data/spec/factories/deploys.rb +8 -1
  36. data/spec/factories/pull_requests.rb +12 -0
  37. data/spec/models/hubstats/comment_spec.rb +2 -2
  38. data/spec/models/hubstats/deploy_spec.rb +20 -20
  39. data/spec/models/hubstats/label_spec.rb +3 -3
  40. data/spec/models/hubstats/pull_request_spec.rb +32 -1
  41. data/spec/models/hubstats/repo_spec.rb +7 -7
  42. data/spec/models/hubstats/user_spec.rb +1 -1
  43. data/test/dummy/db/schema.rb +2 -2
  44. metadata +5 -2
@@ -11,6 +11,17 @@ FactoryGirl.define do
11
11
  association :repository, factory: :repo_hash, strategy: :build
12
12
  id {Faker::Number.number(6).to_i}
13
13
  number {|n| "#{n}".to_i}
14
+ merged_by(:id => 202020)
15
+
16
+ initialize_with { attributes }
17
+ end
18
+
19
+ factory :pull_request_hash_no_merge, class:Hash do
20
+ association :user, factory: :user_hash, strategy: :build
21
+ association :repository, factory: :repo_hash, strategy: :build
22
+ id {Faker::Number.number(6).to_i}
23
+ number {|n| "#{n}".to_i}
24
+ merged_by(nil)
14
25
 
15
26
  initialize_with { attributes }
16
27
  end
@@ -20,6 +31,7 @@ FactoryGirl.define do
20
31
  type "PullRequestEvent"
21
32
  association :repository, factory: :repo_hash, strategy: :build
22
33
  association :pull_request, factory: :pull_request_hash, strategy: :build
34
+ merged_by(:id => 202020)
23
35
 
24
36
  initialize_with { attributes }
25
37
  end
@@ -18,8 +18,8 @@ module Hubstats
18
18
  repo = Repo.create_or_update(github_repo)
19
19
  pull = PullRequest.create_or_update(pull_request)
20
20
  comment = Comment.create_or_update(github_comment)
21
- expect(comment.id).to eq(github_comment[:id])
22
- expect(comment.user_id).to eq(github_user[:id])
21
+ expect(comment.id).to eq(100)
22
+ expect(comment.user_id).to eq(10)
23
23
  end
24
24
  end
25
25
  end
@@ -7,13 +7,13 @@ module Hubstats
7
7
  deploy_hash = {git_revision: "c1a2b37",
8
8
  repo_id: repo.id,
9
9
  deployed_at: "2009-02-03 03:00:00 -0500",
10
- deployed_by: "emmasax1"}
10
+ user_id: 202020}
11
11
  deploy = Deploy.create(deploy_hash)
12
12
  expect(Deploy.count).to eq(1)
13
- expect(deploy.git_revision).to eq(deploy_hash[:git_revision])
14
- expect(deploy.repo_id).to eq(deploy_hash[:repo_id])
15
- expect(deploy.deployed_at).to eq(deploy_hash[:deployed_at])
16
- expect(deploy.deployed_by).to eq(deploy_hash[:deployed_by])
13
+ expect(deploy.git_revision).to eq("c1a2b37")
14
+ expect(deploy.repo_id).to eq(repo.id)
15
+ expect(deploy.deployed_at).to eq("2009-02-03 03:00:00 -0500")
16
+ expect(deploy.user_id).to eq(202020)
17
17
  end
18
18
 
19
19
  it 'should order deploys based on timespan ASC' do
@@ -21,19 +21,19 @@ module Hubstats
21
21
  deploy1 = Deploy.create(git_revision: "c1a2b37",
22
22
  repo_id: repo.id,
23
23
  deployed_at: "2009-12-03 23:00:00",
24
- deployed_by: "emmasax1")
24
+ user_id: 202020)
25
25
  deploy2 = Deploy.create(git_revision: "kd92h10",
26
26
  repo_id: repo.id,
27
27
  deployed_at: "2010-05-26 22:00:00",
28
- deployed_by: "odelltuttle")
28
+ user_id: 202020)
29
29
  deploy3 = Deploy.create(git_revision: "k10d8as",
30
30
  repo_id: repo.id,
31
31
  deployed_at: "2015-08-21 12:00:00",
32
- deployed_by: "EvaMartinuzzi")
32
+ user_id: 202020)
33
33
  deploy4 = Deploy.create(git_revision: "917d9ss",
34
34
  repo_id: repo.id,
35
35
  deployed_at: "2014-12-19 08:00:00",
36
- deployed_by: "panderson74")
36
+ user_id: 202020)
37
37
  deploys_ordered = [deploy1, deploy2, deploy4, deploy3]
38
38
  new_ordered_deploys = Deploy.order_with_timespan(520.weeks, "ASC")
39
39
  expect(Deploy.count).to eq(4)
@@ -45,19 +45,19 @@ module Hubstats
45
45
  deploy1 = Deploy.create(git_revision: "c1a2b37",
46
46
  repo_id: repo.id,
47
47
  deployed_at: "2009-12-03 23:00:00",
48
- deployed_by: "emmasax1")
48
+ user_id: 202020)
49
49
  deploy2 = Deploy.create(git_revision: "kd92h10",
50
50
  repo_id: repo.id,
51
51
  deployed_at: "2010-05-26 22:00:00",
52
- deployed_by: "odelltuttle")
52
+ user_id: 202020)
53
53
  deploy3 = Deploy.create(git_revision: "k10d8as",
54
54
  repo_id: repo.id,
55
55
  deployed_at: "2015-08-21 12:00:00",
56
- deployed_by: "EvaMartinuzzi")
56
+ user_id: 202020)
57
57
  deploy4 = Deploy.create(git_revision: "917d9ss",
58
58
  repo_id: repo.id,
59
59
  deployed_at: "2014-12-19 08:00:00",
60
- deployed_by: "panderson74")
60
+ user_id: 202020)
61
61
  deploys_ordered = [deploy3, deploy4, deploy2, deploy1]
62
62
  new_ordered_deploys = Deploy.order_with_timespan(520.weeks, "DESC")
63
63
  expect(Deploy.count).to eq(4)
@@ -69,7 +69,7 @@ module Hubstats
69
69
  expect(Deploy.create(git_revision: nil,
70
70
  repo_id: repo.id,
71
71
  deployed_at: "2009-02-03 03:00:00 -0500",
72
- deployed_by: "emmasax1")).not_to be_valid
72
+ user_id: 202020)).not_to be_valid
73
73
  end
74
74
 
75
75
  it 'should NOT create a deploy without a repo_id' do
@@ -77,16 +77,16 @@ module Hubstats
77
77
  expect(Deploy.create(git_revision: "c1a2b37",
78
78
  repo_id: nil,
79
79
  deployed_at: "2009-02-03 03:00:00 -0500",
80
- deployed_by: "emmasax1")).not_to be_valid
80
+ user_id: 202020)).not_to be_valid
81
81
  end
82
82
 
83
83
 
84
- it 'should NOT create a deploy without a deployed_by' do
84
+ it 'should create a deploy without a user_id' do
85
85
  repo = build(:repo)
86
86
  expect(Deploy.create(git_revision: "c1a2b37",
87
87
  repo_id: repo.id,
88
88
  deployed_at: "2009-02-03 03:00:00 -0500",
89
- deployed_by: nil)).not_to be_valid
89
+ user_id: nil)).to be_valid
90
90
  end
91
91
 
92
92
  it 'should create a deploy wihtout a deployed_at because nil time turns into current time' do
@@ -94,17 +94,17 @@ module Hubstats
94
94
  expect(Deploy.create(git_revision: "c1a2b37",
95
95
  repo_id: repo.id,
96
96
  deployed_at: nil,
97
- deployed_by: "emmasax1")).to be_valid
97
+ user_id: 202020)).to be_valid
98
98
  end
99
99
 
100
- it 'should NOT create a deploy without an already valid repo_id' do
100
+ it 'should NOT create a deploy with an invalid repo_id' do
101
101
  repo = build(:repo, :id => nil,
102
102
  :name => nil,
103
103
  :full_name => nil)
104
104
  expect(Deploy.create(git_revision: "c1a2b37",
105
105
  repo_id: repo.id,
106
106
  deployed_at: "2009-02-03 03:00:00 -0500",
107
- deployed_by: "emmasax1")).not_to be_valid
107
+ user_id: 202020)).not_to be_valid
108
108
  end
109
109
  end
110
110
  end
@@ -8,9 +8,9 @@ module Hubstats
8
8
  url: "https://api.github.com/repos/sportngin/ngin/labels/feature-request"}
9
9
  label = Label.create(label_hash)
10
10
  expect(Label.count).to eq(1)
11
- expect(label.name).to eq(label_hash[:name])
12
- expect(label.color).to eq(label_hash[:color])
13
- expect(label.url).to eq(label_hash[:url])
11
+ expect(label.name).to eq("Feature request")
12
+ expect(label.color).to eq("FCEC7F")
13
+ expect(label.url).to eq("https://api.github.com/repos/sportngin/ngin/labels/feature-request")
14
14
  end
15
15
  end
16
16
  end
@@ -2,13 +2,44 @@ require 'spec_helper'
2
2
 
3
3
  module Hubstats
4
4
  describe PullRequest, :type => :model do
5
- it 'should create and return a Pull Request' do
5
+ it 'should create and return a pull request with a merge' do
6
6
  pull = build(:pull_request_hash)
7
7
  pull_request = PullRequest.create_or_update(pull)
8
8
  expect(pull_request.id).to eq(pull[:id])
9
9
  expect(pull_request.user_id).to eq(pull[:user][:id])
10
10
  expect(pull_request.repo_id).to eq(pull[:repository][:id])
11
11
  expect(pull_request.number).to eq(pull[:number])
12
+ expect(pull_request.merged_by).to eq(202020)
13
+ end
14
+
15
+ it 'should create and return a pull request without a merge' do
16
+ pull = build(:pull_request_hash_no_merge)
17
+ pull_request = PullRequest.create_or_update(pull)
18
+ expect(pull_request.id).to eq(pull[:id])
19
+ expect(pull_request.user_id).to eq(pull[:user][:id])
20
+ expect(pull_request.repo_id).to eq(pull[:repository][:id])
21
+ expect(pull_request.number).to eq(pull[:number])
22
+ expect(pull_request.merged_by).to eq(nil)
23
+ end
24
+
25
+ it "should create a pull request and update the deploy's user_id" do
26
+ pull = build(:pull_request_hash)
27
+ pull_request = PullRequest.create_or_update(pull)
28
+ dep_hash = {git_revision: "c1a2b37",
29
+ repo_id: 303030,
30
+ deployed_at: "2009-02-03 03:00:00 -0500",
31
+ user_id: nil,
32
+ pull_request_ids: pull[:id]}
33
+ deploy = Hubstats::Deploy.create!(dep_hash)
34
+ pull_request.deploy = deploy
35
+ pull_request = PullRequest.create_or_update(pull)
36
+ expect(pull_request.id).to eq(pull[:id])
37
+ expect(pull_request.user_id).to eq(pull[:user][:id])
38
+ expect(pull_request.repo_id).to eq(pull[:repository][:id])
39
+ expect(pull_request.number).to eq(pull[:number])
40
+ expect(pull_request.merged_by).to eq(202020)
41
+ expect(deploy.user_id).to eq(nil)
42
+ expect(pull_request.deploy.user_id).to eq(202020)
12
43
  end
13
44
  end
14
45
  end
@@ -11,13 +11,13 @@ module Hubstats
11
11
  created_at: "2009-05-27 06:27:04 -0500",
12
12
  updated_at: "2015-03-26 16:17:19 -0500"}
13
13
  repo = Repo.create(repo_hash)
14
- expect(repo.id).to eq(repo_hash[:id])
15
- expect(repo.owner).to eq(repo_hash[:owner])
16
- expect(repo.name).to eq(repo_hash[:name])
17
- expect(repo.full_name).to eq(repo_hash[:full_name])
18
- expect(repo.pushed_at).to eq(repo_hash[:pushed_at])
19
- expect(repo.created_at).to eq(repo_hash[:created_at])
20
- expect(repo.updated_at).to eq(repo_hash[:updated_at])
14
+ expect(repo.id).to eq(131242)
15
+ expect(repo.owner_id).to eq(3728684)
16
+ expect(repo.name).to eq("example_name")
17
+ expect(repo.full_name).to eq("sportngin/example_name")
18
+ expect(repo.pushed_at).to eq("2015-05-27 13:51:21 -0500")
19
+ expect(repo.created_at).to eq("2009-05-27 06:27:04 -0500")
20
+ expect(repo.updated_at).to eq("2015-03-26 16:17:19 -0500")
21
21
  end
22
22
  end
23
23
  end
@@ -16,7 +16,7 @@ module Hubstats
16
16
  user2 = User.create_or_update(build(:user_hash, login: 'johndoe', id: 10))
17
17
  expect(user1).to eq(user2)
18
18
  expect(user2.login).to eq("johndoe")
19
- expect(user2.login).not_to eq("johnapplesdeed")
19
+ expect(user1.login).not_to eq("johnapplesdeed")
20
20
  end
21
21
  end
22
22
  end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20150602210153) do
14
+ ActiveRecord::Schema.define(:version => 20150605190628) do
15
15
 
16
16
  create_table "hubstats_comments", :force => true do |t|
17
17
  t.string "kind"
@@ -40,7 +40,6 @@ ActiveRecord::Schema.define(:version => 20150602210153) do
40
40
  t.string "git_revision"
41
41
  t.integer "repo_id"
42
42
  t.datetime "deployed_at"
43
- t.string "deployed_by"
44
43
  t.integer "user_id"
45
44
  end
46
45
 
@@ -85,6 +84,7 @@ ActiveRecord::Schema.define(:version => 20150602210153) do
85
84
  t.string "merged"
86
85
  t.string "mergeable"
87
86
  t.integer "deploy_id"
87
+ t.integer "merged_by"
88
88
  end
89
89
 
90
90
  add_index "hubstats_pull_requests", ["repo_id"], :name => "index_hubstats_pull_requests_on_repo_id"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Hursh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-05 00:00:00.000000000 Z
12
+ date: 2015-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -188,6 +188,7 @@ files:
188
188
  - app/views/hubstats/partials/_header.html.erb
189
189
  - app/views/hubstats/partials/_pull-condensed.html.erb
190
190
  - app/views/hubstats/partials/_pull.html.erb
191
+ - app/views/hubstats/partials/_quick_addition_stats.html.erb
191
192
  - app/views/hubstats/partials/_quick_stats.html.erb
192
193
  - app/views/hubstats/partials/_repo.html.erb
193
194
  - app/views/hubstats/partials/_user-condensed.html.erb
@@ -220,6 +221,8 @@ files:
220
221
  - db/migrate/20140703200752_create_hubstats_labels_pull_requests.rb
221
222
  - db/migrate/20150526154850_create_hubstats_deploys.rb
222
223
  - db/migrate/20150602205308_add_deploy_column_to_pullrequest.rb
224
+ - db/migrate/20150605184015_add_user_id_delete_deployed_by_to_deploy.rb
225
+ - db/migrate/20150605190549_add_merged_by_column_to_pull_request.rb
223
226
  - db/seeds.rb
224
227
  - hubstats.gemspec
225
228
  - lib/generators/hubstats/install_generator.rb