hubstats 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +9 -0
- data/app/controllers/hubstats/deploys_controller.rb +2 -2
- data/app/controllers/hubstats/pull_requests_controller.rb +1 -1
- data/app/controllers/hubstats/repos_controller.rb +11 -34
- data/app/controllers/hubstats/teams_controller.rb +7 -6
- data/app/controllers/hubstats/users_controller.rb +1 -7
- data/app/helpers/hubstats/metrics_helper.rb +105 -0
- data/app/models/hubstats/comment.rb +2 -0
- data/app/models/hubstats/deploy.rb +15 -1
- data/app/models/hubstats/label.rb +2 -0
- data/app/models/hubstats/pull_request.rb +3 -1
- data/app/models/hubstats/repo.rb +2 -0
- data/app/models/hubstats/team.rb +2 -0
- data/app/models/hubstats/user.rb +3 -1
- data/app/views/hubstats/deploys/index.html.erb +4 -0
- data/app/views/hubstats/deploys/show.html.erb +1 -1
- data/app/views/hubstats/partials/_dashboard.html.erb +14 -0
- data/app/views/hubstats/partials/_header.html.erb +5 -5
- data/app/views/hubstats/partials/_quick_stats_one.html.erb +93 -0
- data/app/views/hubstats/partials/_quick_stats_two.html.erb +93 -0
- data/app/views/hubstats/pull_requests/show.html.erb +1 -1
- data/app/views/hubstats/repos/index.html.erb +14 -0
- data/app/views/hubstats/repos/show.html.erb +2 -2
- data/app/views/hubstats/teams/index.html.erb +3 -0
- data/app/views/hubstats/teams/show.html.erb +2 -2
- data/app/views/hubstats/users/index.html.erb +4 -14
- data/app/views/hubstats/users/show.html.erb +1 -1
- data/config/routes.rb +1 -2
- data/lib/hubstats/engine.rb +1 -0
- data/lib/hubstats/version.rb +1 -1
- data/spec/controllers/hubstats/deploys_controller_spec.rb +18 -15
- data/spec/controllers/hubstats/pull_requests_controller_spec.rb +17 -12
- data/spec/controllers/hubstats/repos_controller_spec.rb +21 -14
- data/spec/controllers/hubstats/teams_controller_spec.rb +5 -4
- data/spec/controllers/hubstats/users_controller_spec.rb +10 -9
- data/spec/factories/comment.rb +3 -1
- data/spec/factories/pull_requests.rb +5 -3
- data/spec/factories/repo.rb +1 -1
- data/spec/factories/users.rb +1 -1
- data/spec/lib/hubstats/events_handler_spec.rb +10 -3
- data/spec/lib/hubstats/github_api_spec.rb +2 -0
- data/spec/models/hubstats/comment_spec.rb +7 -15
- data/spec/models/hubstats/pull_request_spec.rb +22 -4
- data/spec/models/hubstats/team_spec.rb +1 -1
- data/spec/models/hubstats/user_spec.rb +6 -6
- metadata +7 -5
- data/app/views/hubstats/partials/_quick_addition_stats.html.erb +0 -33
- data/app/views/hubstats/partials/_quick_stats.html.erb +0 -69
- data/app/views/hubstats/repos/dashboard.html.erb +0 -24
@@ -6,16 +6,20 @@ module Hubstats
|
|
6
6
|
|
7
7
|
describe "#index" do
|
8
8
|
it "should correctly order all of the pull requests" do
|
9
|
-
user = build(:user)
|
10
|
-
repo = build(:repo)
|
9
|
+
user = build(:user, :updated_at => '2015-12-01')
|
10
|
+
repo = build(:repo, :updated_at => '2015-12-01')
|
11
11
|
pull3 = create(:pull_request, :user => user,
|
12
|
-
:repo => repo
|
12
|
+
:repo => repo,
|
13
|
+
:updated_at => '2015-05-30')
|
13
14
|
pull1 = create(:pull_request, :user => user,
|
14
|
-
:repo => repo
|
15
|
+
:repo => repo,
|
16
|
+
:updated_at => '2015-05-30')
|
15
17
|
pull4 = create(:pull_request, :user => user,
|
16
|
-
:repo => repo
|
18
|
+
:repo => repo,
|
19
|
+
:updated_at => '2015-05-30')
|
17
20
|
pull2 = create(:pull_request, :user => user,
|
18
|
-
:repo => repo
|
21
|
+
:repo => repo,
|
22
|
+
:updated_at => '2015-05-30')
|
19
23
|
pulls_ordered = [pull3, pull1, pull4, pull2]
|
20
24
|
expect(Hubstats::PullRequest).to receive_message_chain("group_by.with_label.state_based_order.paginate").and_return(pulls_ordered)
|
21
25
|
get :index
|
@@ -26,14 +30,15 @@ module Hubstats
|
|
26
30
|
|
27
31
|
describe "#show" do
|
28
32
|
it "should show the comments and deploy of specific pull request" do
|
29
|
-
user = build(:user)
|
30
|
-
repo = build(:repo)
|
33
|
+
user = build(:user, :updated_at => '2015-12-01')
|
34
|
+
repo = build(:repo, :updated_at => '2015-12-01')
|
31
35
|
pull = create(:pull_request, :user => user,
|
32
36
|
:repo => repo,
|
33
|
-
:deploy_id => 404040
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
:deploy_id => 404040,
|
38
|
+
:updated_at => '2015-05-30')
|
39
|
+
comment1 = create(:comment, :pull_request_id => pull.id, :created_at => Date.today, :updated_at => '2015-12-01', user: user)
|
40
|
+
comment2 = create(:comment, :pull_request_id => pull.id, :created_at => Date.today, :updated_at => '2015-12-01', user: user)
|
41
|
+
comment3 = create(:comment, :pull_request_id => pull.id, :created_at => Date.today, :updated_at => '2015-12-01', user: user)
|
37
42
|
get :show, repo: repo, id: pull.id
|
38
43
|
expect(assigns(:pull_request)).to eq(pull)
|
39
44
|
expect(assigns(:pull_request).repo_id).to eq(101010)
|
@@ -9,19 +9,19 @@ module Hubstats
|
|
9
9
|
repo1 = create(:repo, :id => 101010,
|
10
10
|
:name => "silly",
|
11
11
|
:full_name => "sportngin/silly",
|
12
|
-
:updated_at =>
|
12
|
+
:updated_at => Date.today)
|
13
13
|
repo2 = create(:repo, :id => 202020,
|
14
14
|
:name => "funny",
|
15
15
|
:full_name => "sportngin/funny",
|
16
|
-
:updated_at =>
|
16
|
+
:updated_at => Date.today)
|
17
17
|
repo3 = create(:repo, :id => 303030,
|
18
18
|
:name => "loosey",
|
19
19
|
:full_name => "sportngin/loosey",
|
20
|
-
:updated_at =>
|
20
|
+
:updated_at => Date.today)
|
21
21
|
repo4 = create(:repo, :id => 404040,
|
22
22
|
:name => "goosey",
|
23
23
|
:full_name => "sportngin/goosey",
|
24
|
-
:updated_at =>
|
24
|
+
:updated_at => Date.today)
|
25
25
|
get :index
|
26
26
|
expect(assigns(:repos)).to contain_exactly(repo2, repo1, repo3, repo4)
|
27
27
|
end
|
@@ -29,15 +29,18 @@ module Hubstats
|
|
29
29
|
|
30
30
|
describe "#show" do
|
31
31
|
it "should show the pull requests and deploys of specific repository" do
|
32
|
+
user = create(:user, :id => 606060, :updated_at => '2015-08-12')
|
32
33
|
repo = create(:repo, :id => 101010,
|
33
34
|
:name => "example",
|
34
35
|
:full_name => "sportngin/example",
|
35
|
-
:owner_id =>
|
36
|
+
:owner_id => user.id,
|
37
|
+
:updated_at => Date.today)
|
36
38
|
pull1 = create(:pull_request, :repo_id => 101010,
|
37
|
-
:updated_at => "2015-06-02 19:49:42"
|
39
|
+
:updated_at => "2015-06-02 19:49:42",
|
40
|
+
:user => user)
|
38
41
|
pull2 = create(:pull_request, :repo_id => 101010,
|
39
|
-
:updated_at => "2015-04-21 17:06:31"
|
40
|
-
|
42
|
+
:updated_at => "2015-04-21 17:06:31",
|
43
|
+
:user => user)
|
41
44
|
deploy1 = create(:deploy, :repo_id => 101010)
|
42
45
|
deploy2 = create(:deploy, :repo_id => 101010)
|
43
46
|
get :show, repo: repo.name
|
@@ -49,22 +52,26 @@ module Hubstats
|
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
52
|
-
describe "#
|
55
|
+
describe "#index" do
|
53
56
|
it "should list all of the repos and the basic metrics" do
|
54
57
|
repo1 = create(:repo, :id => 101010,
|
55
58
|
:name => "silly",
|
56
|
-
:full_name => "sportngin/silly"
|
59
|
+
:full_name => "sportngin/silly",
|
60
|
+
:updated_at => Date.today)
|
57
61
|
repo2 = create(:repo, :id => 202020,
|
58
62
|
:name => "funny",
|
59
|
-
:full_name => "sportngin/funny"
|
63
|
+
:full_name => "sportngin/funny",
|
64
|
+
:updated_at => Date.today)
|
60
65
|
repo3 = create(:repo, :id => 303030,
|
61
66
|
:name => "loosey",
|
62
|
-
:full_name => "sportngin/loosey"
|
67
|
+
:full_name => "sportngin/loosey",
|
68
|
+
:updated_at => Date.today)
|
63
69
|
repo4 = create(:repo, :id => 404040,
|
64
70
|
:name => "goosey",
|
65
|
-
:full_name => "sportngin/goosey"
|
71
|
+
:full_name => "sportngin/goosey",
|
72
|
+
:updated_at => Date.today)
|
66
73
|
expect(Hubstats::Repo).to receive_message_chain("with_id.custom_order.paginate").and_return([repo1, repo2, repo3, repo4])
|
67
|
-
get :
|
74
|
+
get :index
|
68
75
|
expect(response).to have_http_status(200)
|
69
76
|
end
|
70
77
|
end
|
@@ -20,12 +20,13 @@ module Hubstats
|
|
20
20
|
describe "#show" do
|
21
21
|
it "should return the team and all of its users and pull requests" do
|
22
22
|
team = create(:team, :name => "Team Tests Passing", :hubstats => true, :id => 1)
|
23
|
-
user1 = create(:user, :id => 101010, :login => "examplePerson1")
|
24
|
-
user2 = create(:user, :id => 202020, :login => "examplePerson2")
|
23
|
+
user1 = create(:user, :id => 101010, :login => "examplePerson1", :updated_at => Date.today)
|
24
|
+
user2 = create(:user, :id => 202020, :login => "examplePerson2", :updated_at => Date.today)
|
25
|
+
repo = create(:repo, :updated_at => Date.today)
|
25
26
|
team.users << user1
|
26
27
|
team.users << user2
|
27
|
-
pull1 = create(:pull_request, :user => user1, :id => 303030, :team => team)
|
28
|
-
pull2 = create(:pull_request, :user => user2, :id => 404040, :team => team, :repo => pull1.repo)
|
28
|
+
pull1 = create(:pull_request, :user => user1, :id => 303030, :team => team, :repo_id => repo.id, :updated_at => Date.today)
|
29
|
+
pull2 = create(:pull_request, :user => user2, :id => 404040, :team => team, :repo => pull1.repo, :updated_at => Date.today)
|
29
30
|
allow(Hubstats).to receive_message_chain(:config, :github_config, :[]).with("ignore_users_list") { ["user"] }
|
30
31
|
get :show, id: 1
|
31
32
|
expect(assigns(:team)).to eq(team)
|
@@ -6,10 +6,10 @@ module Hubstats
|
|
6
6
|
|
7
7
|
describe "#index" do
|
8
8
|
it "should show all of the users" do
|
9
|
-
user2 = create(:user, :id => 101010, :login => "examplePerson1")
|
10
|
-
user1 = create(:user, :id => 202020, :login => "examplePerson2")
|
11
|
-
user3 = create(:user, :id => 303030, :login => "examplePerson3")
|
12
|
-
user4 = create(:user, :id => 404040, :login => "examplePerson4")
|
9
|
+
user2 = create(:user, :id => 101010, :login => "examplePerson1", :updated_at => Date.today)
|
10
|
+
user1 = create(:user, :id => 202020, :login => "examplePerson2", :updated_at => Date.today)
|
11
|
+
user3 = create(:user, :id => 303030, :login => "examplePerson3", :updated_at => Date.today)
|
12
|
+
user4 = create(:user, :id => 404040, :login => "examplePerson4", :updated_at => Date.today)
|
13
13
|
expect(Hubstats::User).to receive_message_chain("with_id.custom_order.paginate").and_return([user2, user3, user1, user4])
|
14
14
|
get :index
|
15
15
|
expect(response).to have_http_status(200)
|
@@ -18,13 +18,14 @@ module Hubstats
|
|
18
18
|
|
19
19
|
describe "#show" do
|
20
20
|
it "should show the pull requests and deploys of specific user" do
|
21
|
-
user = create(:user, :id => 101010, :login => "examplePerson")
|
22
|
-
|
23
|
-
|
21
|
+
user = create(:user, :id => 101010, :login => "examplePerson", :updated_at => Date.today)
|
22
|
+
repo = create(:repo, :updated_at => Date.today)
|
23
|
+
pull1 = create(:pull_request, :user => user, :id => 202020, :updated_at => Date.today, :repo_id => repo.id)
|
24
|
+
pull2 = create(:pull_request, :user => user, :id => 303030, :repo => pull1.repo, :updated_at => Date.today)
|
24
25
|
deploy1 = create(:deploy, :user_id => 101010)
|
25
26
|
deploy2 = create(:deploy, :user_id => 101010)
|
26
|
-
comment1 = create(:comment, :user => user)
|
27
|
-
comment2 = create(:comment, :user => user)
|
27
|
+
comment1 = create(:comment, :user => user, :updated_at => Date.today)
|
28
|
+
comment2 = create(:comment, :user => user, :updated_at => Date.today)
|
28
29
|
get :show, id: "examplePerson"
|
29
30
|
expect(assigns(:user)).to eq(user)
|
30
31
|
expect(assigns(:user).pull_requests).to contain_exactly(pull1, pull2)
|
data/spec/factories/comment.rb
CHANGED
@@ -4,18 +4,20 @@ FactoryGirl.define do
|
|
4
4
|
user
|
5
5
|
id {Faker::Number.number(6).to_i}
|
6
6
|
body {Faker::Lorem.sentence}
|
7
|
+
created_at '2015-05-30'
|
7
8
|
end
|
8
9
|
|
9
10
|
factory :comment_hash, class:Hash do
|
10
11
|
association :user, factory: :user_hash, strategy: :build
|
11
12
|
id {Faker::Number.number(6).to_i}
|
12
13
|
body {Faker::Lorem.sentence}
|
13
|
-
initialize_with { attributes }
|
14
|
+
initialize_with { attributes }
|
14
15
|
end
|
15
16
|
|
16
17
|
factory :comment_payload_hash, class:Hash do
|
17
18
|
id {Faker::Number.number(6).to_i}
|
18
19
|
type ["IssueCommentEvent", "CommitCommentEvent", "PullRequestReviewCommentEvent"].sample
|
20
|
+
association :user, factory: :user_hash, strategy: :build
|
19
21
|
association :repository, factory: :repo_hash, strategy: :build
|
20
22
|
association :pull_request, factory: :pull_request_hash, strategy: :build
|
21
23
|
association :comment, factory: :comment_hash, strategy: :build
|
@@ -5,6 +5,7 @@ FactoryGirl.define do
|
|
5
5
|
repo
|
6
6
|
id {Faker::Number.number(6).to_i}
|
7
7
|
number {|n| "#{n}".to_i}
|
8
|
+
created_at '2015-05-30'
|
8
9
|
end
|
9
10
|
|
10
11
|
factory :pull_request_hash, class:Hash do
|
@@ -13,7 +14,8 @@ FactoryGirl.define do
|
|
13
14
|
id {Faker::Number.number(6).to_i}
|
14
15
|
number {|n| "#{n}".to_i}
|
15
16
|
merged_by(:id => 202020)
|
16
|
-
|
17
|
+
created_at Date.today
|
18
|
+
updated_at Date.today
|
17
19
|
initialize_with { attributes }
|
18
20
|
end
|
19
21
|
|
@@ -23,7 +25,8 @@ FactoryGirl.define do
|
|
23
25
|
id {Faker::Number.number(6).to_i}
|
24
26
|
number {|n| "#{n}".to_i}
|
25
27
|
merged_by(nil)
|
26
|
-
|
28
|
+
created_at Date.today
|
29
|
+
updated_at Date.today
|
27
30
|
initialize_with { attributes }
|
28
31
|
end
|
29
32
|
|
@@ -33,7 +36,6 @@ FactoryGirl.define do
|
|
33
36
|
association :repository, factory: :repo_hash, strategy: :build
|
34
37
|
association :pull_request, factory: :pull_request_hash, strategy: :build
|
35
38
|
merged_by(:id => 202020)
|
36
|
-
|
37
39
|
initialize_with { attributes }
|
38
40
|
end
|
39
41
|
end
|
data/spec/factories/repo.rb
CHANGED
@@ -4,13 +4,13 @@ FactoryGirl.define do
|
|
4
4
|
id 101010
|
5
5
|
name "hubstats"
|
6
6
|
full_name "hub/hubstats"
|
7
|
+
created_at '2015-05-30'
|
7
8
|
end
|
8
9
|
|
9
10
|
factory :repo_hash, class:Hash do
|
10
11
|
id 101010
|
11
12
|
name "Hubstats"
|
12
13
|
full_name "hub/hubstats"
|
13
|
-
|
14
14
|
initialize_with { attributes }
|
15
15
|
end
|
16
16
|
end
|
data/spec/factories/users.rb
CHANGED
@@ -4,13 +4,13 @@ FactoryGirl.define do
|
|
4
4
|
login { Faker::Internet.user_name }
|
5
5
|
id {|n| "#{n}".to_i}
|
6
6
|
role "User"
|
7
|
+
created_at '2015-05-30'
|
7
8
|
end
|
8
9
|
|
9
10
|
factory :user_hash, class:Hash do
|
10
11
|
login { Faker::Internet.user_name }
|
11
12
|
id {|n| "#{n}".to_i}
|
12
13
|
role "User"
|
13
|
-
|
14
14
|
initialize_with { attributes }
|
15
15
|
end
|
16
16
|
end
|
@@ -3,8 +3,9 @@ require 'spec_helper'
|
|
3
3
|
module Hubstats
|
4
4
|
describe EventsHandler, :type => :model do
|
5
5
|
context "PullRequestEvent" do
|
6
|
-
let(:
|
7
|
-
let(:repo) {build(:repo)}
|
6
|
+
let(:user) {build(:user, :updated_at => Date.today)}
|
7
|
+
let(:repo) {build(:repo, :updated_at => Date.today)}
|
8
|
+
let(:pull) {build(:pull_request, :updated_at => Date.today, :user => user, :repo => repo)}
|
8
9
|
let(:payload) {build(:pull_request_payload_hash)}
|
9
10
|
|
10
11
|
subject {Hubstats::EventsHandler.new()}
|
@@ -23,6 +24,8 @@ module Hubstats
|
|
23
24
|
end
|
24
25
|
|
25
26
|
context "CommentEvent" do
|
27
|
+
let(:user) {build(:user, :updated_at => Date.today, :created_at => '2015-01-01', :login => "hermina", :id => 0, :role => "User")}
|
28
|
+
|
26
29
|
it 'should successfully route the event' do
|
27
30
|
ehandler = EventsHandler.new()
|
28
31
|
payload = build(:comment_payload_hash)
|
@@ -39,7 +42,11 @@ module Hubstats
|
|
39
42
|
|
40
43
|
it 'should successfully creates_or_updates the event' do
|
41
44
|
ehandler = Hubstats::EventsHandler.new()
|
42
|
-
payload = build(:comment_payload_hash
|
45
|
+
payload = build(:comment_payload_hash, :user => {:login=>"hermina", :id=>0, :role=>"User"},
|
46
|
+
:comment => {"id"=>194761, "body"=>"Quidem ea minus ut odio optio.",
|
47
|
+
"kind"=>"Issue", "user_id"=>0, "repo_id"=>101010,
|
48
|
+
"created_at" => Date.today, "updated_at" => Date.today})
|
49
|
+
allow(Hubstats::User).to receive_message_chain(:create_or_update).and_return(user)
|
43
50
|
expect(ehandler.route(payload, payload[:type]).class).to eq(Hubstats::Comment)
|
44
51
|
end
|
45
52
|
end
|
@@ -78,6 +78,7 @@ module Hubstats
|
|
78
78
|
let(:user1) {build(:user_hash)}
|
79
79
|
let(:user2) {build(:user_hash)}
|
80
80
|
let(:user3) {build(:user_hash)}
|
81
|
+
let(:finished_user) {build(:user, :created_at => Date.today, :updated_at => Date.today)}
|
81
82
|
let(:hubstats_user) {build(:user)}
|
82
83
|
let(:access_token) { "access_token" }
|
83
84
|
let(:user) { double }
|
@@ -94,6 +95,7 @@ module Hubstats
|
|
94
95
|
allow(Hubstats::Team).to receive_message_chain(:where, :name).with("Team One")
|
95
96
|
allow(Hubstats::Team.where(name: "Team One")).to receive(:first).and_return(team)
|
96
97
|
allow(client).to receive_message_chain(:rate_limit, :remaining).and_return(500)
|
98
|
+
allow(Hubstats::User).to receive(:create_or_update).and_return(finished_user)
|
97
99
|
expect(Hubstats::Team).to receive(:create_or_update).at_least(:once)
|
98
100
|
subject.update_teams
|
99
101
|
end
|
@@ -3,21 +3,13 @@ require 'spec_helper'
|
|
3
3
|
module Hubstats
|
4
4
|
describe Comment, :type => :model do
|
5
5
|
it 'should create and return a comment and user' do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
:name => "HelloWorld"}
|
14
|
-
pull_request = {:id => 1000,
|
15
|
-
:url => "www.pull.com",
|
16
|
-
:repository => github_repo,
|
17
|
-
:user => github_user}
|
18
|
-
repo = Repo.create_or_update(github_repo)
|
19
|
-
pull = PullRequest.create_or_update(pull_request)
|
20
|
-
comment = Comment.create_or_update(github_comment)
|
6
|
+
repo = build(:repo, :created_at => Date.today, :updated_at => Date.today)
|
7
|
+
user = build(:user, :created_at => Date.today, :updated_at => Date.today,
|
8
|
+
:login => "elliothursh", :id => 10)
|
9
|
+
comment = build(:comment, :created_at => Date.today, :updated_at => Date.today,
|
10
|
+
:user => user, :pull_request_url => "www.pull.com", :id => 100, :repo => repo)
|
11
|
+
pull_request = build(:pull_request, :created_at => Date.today, :updated_at => Date.today,
|
12
|
+
:id => 1000, :url => "www.pull.com", :repo => repo, :user => user)
|
21
13
|
expect(comment.id).to eq(100)
|
22
14
|
expect(comment.user_id).to eq(10)
|
23
15
|
end
|
@@ -4,6 +4,10 @@ module Hubstats
|
|
4
4
|
describe PullRequest, :type => :model do
|
5
5
|
it 'should create and return a pull request with a merge' do
|
6
6
|
pull = build(:pull_request_hash)
|
7
|
+
user = create(:user, :created_at => Date.today, :updated_at => Date.today)
|
8
|
+
repo = create(:repo, :created_at => Date.today, :updated_at => Date.today)
|
9
|
+
allow(Hubstats::User).to receive(:create_or_update).and_return(user)
|
10
|
+
allow(Hubstats::Repo).to receive(:create_or_update).and_return(repo)
|
7
11
|
pull_request = PullRequest.create_or_update(pull)
|
8
12
|
expect(pull_request.id).to eq(pull[:id])
|
9
13
|
expect(pull_request.user_id).to eq(pull[:user][:id])
|
@@ -14,6 +18,10 @@ module Hubstats
|
|
14
18
|
|
15
19
|
it 'should create and return a pull request without a merge' do
|
16
20
|
pull = build(:pull_request_hash_no_merge)
|
21
|
+
user = create(:user, :created_at => Date.today, :updated_at => Date.today)
|
22
|
+
repo = create(:repo, :created_at => Date.today, :updated_at => Date.today)
|
23
|
+
allow(Hubstats::User).to receive(:create_or_update).and_return(user)
|
24
|
+
allow(Hubstats::Repo).to receive(:create_or_update).and_return(repo)
|
17
25
|
pull_request = PullRequest.create_or_update(pull)
|
18
26
|
expect(pull_request.id).to eq(pull[:id])
|
19
27
|
expect(pull_request.user_id).to eq(pull[:user][:id])
|
@@ -23,7 +31,11 @@ module Hubstats
|
|
23
31
|
end
|
24
32
|
|
25
33
|
it "should create a pull request and update the deploy's user_id" do
|
34
|
+
user = create(:user, :created_at => Date.today, :updated_at => Date.today)
|
35
|
+
repo = create(:repo, :created_at => Date.today, :updated_at => Date.today)
|
26
36
|
pull = build(:pull_request_hash)
|
37
|
+
allow(Hubstats::User).to receive(:create_or_update).and_return(user)
|
38
|
+
allow(Hubstats::Repo).to receive(:create_or_update).and_return(repo)
|
27
39
|
pull_request = PullRequest.create_or_update(pull)
|
28
40
|
dep_hash = {git_revision: "c1a2b37",
|
29
41
|
repo_id: 303030,
|
@@ -44,10 +56,13 @@ module Hubstats
|
|
44
56
|
|
45
57
|
it "should track the team_id when making a pull request" do
|
46
58
|
user_hash = {login: 'name', id: '12345'}
|
47
|
-
user =
|
59
|
+
user = create(:user, :created_at => Date.today, :updated_at => Date.today)
|
60
|
+
repo = create(:repo, :created_at => Date.today, :updated_at => Date.today)
|
48
61
|
team = create(:team, id: 1010)
|
49
62
|
team.users << user
|
50
63
|
pull = build(:pull_request_hash, :user => user_hash)
|
64
|
+
allow(Hubstats::User).to receive(:create_or_update).and_return(user)
|
65
|
+
allow(Hubstats::Repo).to receive(:create_or_update).and_return(repo)
|
51
66
|
pull_request = PullRequest.create_or_update(pull)
|
52
67
|
expect(pull_request.user_id).to eq(user[:id])
|
53
68
|
expect(pull_request.team_id).to eq(team[:id])
|
@@ -55,8 +70,11 @@ module Hubstats
|
|
55
70
|
|
56
71
|
it "should leave the team_id of a pull request blank if user is not part of a team" do
|
57
72
|
user_hash = {login: 'name', id: '12345'}
|
58
|
-
|
73
|
+
repo = create(:repo, :created_at => Date.today, :updated_at => Date.today)
|
74
|
+
user = build(:user, :created_at => Date.today, :updated_at => Date.today)
|
59
75
|
pull = build(:pull_request_hash, :user => user_hash)
|
76
|
+
allow(Hubstats::User).to receive(:create_or_update).and_return(user)
|
77
|
+
allow(Hubstats::Repo).to receive(:create_or_update).and_return(repo)
|
60
78
|
pull_request = PullRequest.create_or_update(pull)
|
61
79
|
expect(pull_request.user_id).to eq(user[:id])
|
62
80
|
expect(pull_request.team_id).to eq(nil)
|
@@ -64,12 +82,12 @@ module Hubstats
|
|
64
82
|
|
65
83
|
it 'should update the team_ids in pull requests' do
|
66
84
|
team = build(:team)
|
67
|
-
repo = build(:repo)
|
85
|
+
repo = build(:repo, :updated_at => Date.today)
|
68
86
|
user1 = build(:user)
|
69
87
|
user2 = build(:user, :id => 7)
|
70
88
|
team.users << user1
|
71
89
|
team.users << user2
|
72
|
-
pull1 = build(:pull_request, :created_at => Date.today - 250, :user => user1)
|
90
|
+
pull1 = build(:pull_request, :created_at => Date.today - 250, :user => user1, :repo => repo)
|
73
91
|
pull2 = build(:pull_request, :created_at => Date.today - 3, :repo => repo, :user => user2)
|
74
92
|
Hubstats::PullRequest.update_teams_in_pulls(365)
|
75
93
|
expect(pull1.team_id).to eq(team.id)
|
@@ -12,7 +12,7 @@ module Hubstats
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should add a member to a team' do
|
15
|
-
user = build(:user)
|
15
|
+
user = build(:user, :created_at => Date.today, :updated_at => Date.today)
|
16
16
|
action = "added"
|
17
17
|
team = build(:team)
|
18
18
|
Hubstats::Team.update_users_in_team(team, user, action)
|
@@ -7,13 +7,13 @@ module Hubstats
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should create and return a user' do
|
10
|
-
user = build(:user_hash, id: 10)
|
10
|
+
user = build(:user_hash, id: 10, :created_at => Date.today, :updated_at => Date.today)
|
11
11
|
expect(User.create_or_update(user).id).to eq(10)
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should update a user based off id' do
|
15
|
-
user1 = User.create_or_update(build(:user_hash, login: 'johnappleseed', id: 10))
|
16
|
-
user2 = User.create_or_update(build(:user_hash, login: 'johndoe', id: 10))
|
15
|
+
user1 = User.create_or_update(build(:user_hash, login: 'johnappleseed', id: 10, :created_at => Date.today, :updated_at => Date.today))
|
16
|
+
user2 = User.create_or_update(build(:user_hash, login: 'johndoe', id: 10, :created_at => Date.today, :updated_at => Date.today))
|
17
17
|
expect(user1).to eq(user2)
|
18
18
|
expect(user2.login).to eq("johndoe")
|
19
19
|
expect(user1.login).not_to eq("johnapplesdeed")
|
@@ -21,7 +21,7 @@ module Hubstats
|
|
21
21
|
|
22
22
|
it 'should find the team that this user belongs to' do
|
23
23
|
team = create(:team)
|
24
|
-
user = create(:user, login: 'janedoe', id: 11)
|
24
|
+
user = create(:user, login: 'janedoe', id: 11, :created_at => Date.today, :updated_at => Date.today)
|
25
25
|
team.users << user
|
26
26
|
expect(user.login).to eq('janedoe')
|
27
27
|
expect(user.team).to eq(team)
|
@@ -30,7 +30,7 @@ module Hubstats
|
|
30
30
|
it 'should find first team that this user belongs to' do
|
31
31
|
team1 = create(:team, name: "sad")
|
32
32
|
team2 = create(:team, name: "happy")
|
33
|
-
user = create(:user, login: 'janedoe', id: 11)
|
33
|
+
user = create(:user, login: 'janedoe', id: 11, :created_at => Date.today, :updated_at => Date.today)
|
34
34
|
team1.users << user
|
35
35
|
team2.users << user
|
36
36
|
expect(user.login).to eq('janedoe')
|
@@ -39,7 +39,7 @@ module Hubstats
|
|
39
39
|
|
40
40
|
it 'should return no team if the hubstats bool is false' do
|
41
41
|
team = create(:team, hubstats: false)
|
42
|
-
user = create(:user, login: 'janedoe', id: 11)
|
42
|
+
user = create(:user, login: 'janedoe', id: 11, :created_at => Date.today, :updated_at => Date.today)
|
43
43
|
team.users << user
|
44
44
|
expect(user.login).to eq('janedoe')
|
45
45
|
expect(user.team).to eq(nil)
|