Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Commit 20fae19

Browse files
Merge pull request #422 from BRIMIL01/test_cleanup
Test cleanup
2 parents a4736c0 + 07977ad commit 20fae19

File tree

14 files changed

+154
-157
lines changed

14 files changed

+154
-157
lines changed

app/lib/git_hub/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def check_rate_limit(response)
118118
def reset_time(response)
119119
seconds = response.headers['X-RateLimit-Reset'].to_i
120120

121-
Time.at(seconds).strftime '%-m/%d/%Y at%l:%M:%S%P %Z'
121+
Time.at(seconds).utc.strftime '%-m/%d/%Y at%l:%M:%S%P %Z'
122122
end
123123
end
124124
end

test/controllers/api/v1/airtable/mentorships_controller_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class Api::V1::Airtable::MentorshipsControllerTest < ActionDispatch::Integration
1010
VCR.use_cassette('airtable/mentorship/successful') do
1111
get api_v1_airtable_mentorships_path, headers: @headers, as: :json
1212

13-
assert response.status == 200
14-
assert response.parsed_body.keys.sort == ['mentors', 'services', 'skillsets']
13+
assert_equal 200, response.status
14+
assert_equal ['mentors', 'services', 'skillsets'], response.parsed_body.keys.sort
1515
end
1616
end
1717

1818
test ':index when rate limit returns a 422 and error message' do
1919
VCR.use_cassette('airtable/mentorship/exceeded_rate_limit') do
2020
get api_v1_airtable_mentorships_path, headers: @headers, as: :json
2121

22-
assert response.status == 422
22+
assert_equal 422, response.status
2323
assert response.parsed_body['error'].present?
2424
end
2525
end
@@ -42,7 +42,7 @@ class Api::V1::Airtable::MentorshipsControllerTest < ActionDispatch::Integration
4242
as: :json
4343
)
4444

45-
assert response.status == 201
45+
assert_equal 201, response.status
4646
assert response.parsed_body['id'].present?
4747
assert response.parsed_body['createdTime'].present?
4848
end
@@ -66,7 +66,7 @@ class Api::V1::Airtable::MentorshipsControllerTest < ActionDispatch::Integration
6666
as: :json
6767
)
6868

69-
assert response.status == 201
69+
assert_equal 201, response.status
7070
assert response.parsed_body['id'].present?
7171
assert response.parsed_body['createdTime'].present?
7272
end

test/controllers/api/v1/code_schools_controller_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ class Api::V1::CodeSchoolsControllerTest < ActionDispatch::IntegrationTest
6464
dojo = code_schools[0]
6565
wynode = code_schools[1]
6666

67-
assert dojo['name'] == coding_dojo.name
68-
assert wynode['name'] == wynode_academy.name
67+
assert_equal dojo['name'], coding_dojo.name
68+
assert_equal wynode['name'], wynode_academy.name
6969

70-
assert cities_for(dojo) == [dojo_la.city, dojo_san_fran.city]
71-
assert cities_for(wynode) == [wynode_denver.city, wynode_dallas.city]
70+
assert_equal cities_for(dojo), [dojo_la.city, dojo_san_fran.city]
71+
assert_equal cities_for(wynode), [wynode_denver.city, wynode_dallas.city]
7272
end
7373

7474
test ':create endpoint creates a CodeSchool successfully' do

test/controllers/api/v1/slack_users_controller_test.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class Api::V1::SlackUsersControllerTest < ActionDispatch::IntegrationTest
1010

1111
body = JSON.parse(response.body)
1212

13-
assert response.status == 200
14-
assert body == { 'message' => 'You have access!' }
13+
assert_equal response.status, 200
14+
assert_equal body, { 'message' => 'You have access!' }
1515
end
1616

1717
test ':access returns a 401 with an incorrect token' do
@@ -23,8 +23,8 @@ class Api::V1::SlackUsersControllerTest < ActionDispatch::IntegrationTest
2323

2424
body = JSON.parse(response.body)
2525

26-
assert response.status == 401
27-
assert body == { 'errors' => ['Auth token is invalid'] }
26+
assert_equal response.status, 401
27+
assert_equal body, { 'errors' => ['Auth token is invalid'] }
2828
end
2929

3030
test ':access returns a 401 with an expired token' do
@@ -36,8 +36,8 @@ class Api::V1::SlackUsersControllerTest < ActionDispatch::IntegrationTest
3636

3737
body = JSON.parse(response.body)
3838

39-
assert response.status == 401
40-
assert body == { 'errors' => ['Auth token has expired'] }
39+
assert_equal response.status, 401
40+
assert_equal body, { 'errors' => ['Auth token has expired'] }
4141
end
4242

4343
test ':access returns a 401 with a malformed token' do
@@ -49,8 +49,8 @@ class Api::V1::SlackUsersControllerTest < ActionDispatch::IntegrationTest
4949

5050
body = JSON.parse(response.body)
5151

52-
assert response.status == 401
53-
assert body == { 'errors' => ['Invalid auth token'] }
52+
assert_equal response.status, 401
53+
assert_equal body, { 'errors' => ['Invalid auth token'] }
5454
end
5555
end
5656

test/lib/git_hub/authentication_test.rb

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,46 @@ class GitHub::AuthenticationTest < ActiveSupport::TestCase
2121
end
2222

2323
test 'initialize constructs the expected variable' do
24-
assert @instance.options == @options
25-
assert @instance.auth_level == GitHub::Authentication::O_AUTH_2_KEY_SECRET
24+
assert_equal @options, @instance.options
25+
assert_equal GitHub::Authentication::O_AUTH_2_KEY_SECRET, @instance.auth_level
2626
end
2727

2828
test '#set_options returns the passed in options when Rails.env.prod? is false' do
29-
assert @instance.set_options == @options
29+
assert @options, @instance.set_options
3030
end
3131

3232
test '#set_options merges the authenticated OAUTH_KEY options hash when Rails.env.prod? is true' do
3333
Rails.env.stubs(:prod?).returns(true)
3434

35-
assert @instance.set_options == {
36-
:query =>
37-
{
38-
:client_id => 'some random id',
39-
:client_secret => 'some random key',
40-
:per_page => 100
41-
},
42-
:headers =>
43-
{
44-
'Accepts' => 'application/vnd.github.v3+json',
45-
'User-Agent' => 'operationcode'
46-
}
47-
}
35+
assert_equal @instance.set_options,
36+
:query =>
37+
{
38+
:client_id => 'some random id',
39+
:client_secret => 'some random key',
40+
:per_page => 100
41+
},
42+
:headers =>
43+
{
44+
'Accepts' => 'application/vnd.github.v3+json',
45+
'User-Agent' => 'operationcode'
46+
}
4847
end
4948

5049
test '#set_options merges the authenticated OAUTH_TOKEN options hash when Rails.env.prod? is true' do
5150
GitHub::Settings.stubs(:authentication_level).returns(GitHub::Authentication::O_AUTH_2_TOKEN)
5251
Rails.env.stubs(:prod?).returns(true)
5352

5453
instance = GitHub::Authentication.new(@options)
55-
assert instance.set_options == {
56-
:query =>
57-
{
58-
:per_page => 100
59-
},
60-
:headers =>
61-
{
62-
'Accepts' => 'application/vnd.github.v3+json',
63-
'User-Agent' => 'operationcode',
64-
'Authorization' => "Bearer #{GitHub::Settings.o_auth_2_token}"
65-
}
66-
}
54+
assert_equal instance.set_options,
55+
:query =>
56+
{
57+
:per_page => 100
58+
},
59+
:headers =>
60+
{
61+
'Accepts' => 'application/vnd.github.v3+json',
62+
'User-Agent' => 'operationcode',
63+
'Authorization' => "Bearer #{GitHub::Settings.o_auth_2_token}"
64+
}
6765
end
6866
end

test/lib/git_hub/committer_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ class GitHub::CommitterTest < ActiveSupport::TestCase
3232

3333
user = GitHub::Committer.find_or_create_user! @user_attrs
3434

35-
assert GitHubUser.first == user
35+
assert_equal user, GitHubUser.first
3636
end
3737

3838
test '.find_or_create_user! returns the existing matched user' do
3939
user = create :git_hub_user, git_hub_login: @user_attrs[:login]
4040
results = GitHub::Committer.find_or_create_user! @user_attrs.merge(id: user.git_hub_id)
4141

42-
assert results == user
42+
assert_equal user, results
4343
end
4444

4545
test '.find_or_create_statistic! creates and returns non-existing GitHubStatistic' do
@@ -51,7 +51,7 @@ class GitHub::CommitterTest < ActiveSupport::TestCase
5151
create(:git_hub_user).id
5252
)
5353

54-
assert GitHubStatistic.first == stat
54+
assert_equal stat, GitHubStatistic.first
5555
end
5656

5757
test '.find_or_create_statistic! returns the existing matched user' do
@@ -68,6 +68,6 @@ class GitHub::CommitterTest < ActiveSupport::TestCase
6868
user.git_hub_id
6969
)
7070

71-
assert results == stat
71+
assert_equal stat, results
7272
end
7373
end

test/lib/send_grid_client/guest_test.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,23 @@ class SendGridClient::GuestTest < ActiveSupport::TestCase
1010
test "#user creates an :id method that defaults to 'guest-id'" do
1111
guest = SendGridClient::Guest.user(valid_email)
1212

13-
assert guest.id == 'guest-id'
13+
assert 'guest-id', guest.id
1414
end
1515

1616
test '#user creates an :email method that is set to the passed email address' do
1717
guest = SendGridClient::Guest.user(valid_email)
1818

19-
assert guest.email == valid_email
19+
assert_equal valid_email, guest.email
2020
end
2121

2222
test "#attributes returns JSON for the Struct's id, first_name, last_name, and email" do
2323
guest = SendGridClient::Guest.user(valid_email)
2424

25-
assert guest.attributes == {
26-
'id' => 'guest-id',
27-
'email' => valid_email,
28-
'first_name' => '',
29-
'last_name' => ''
30-
}
25+
assert_equal guest.attributes,
26+
'id' => 'guest-id',
27+
'email' => valid_email,
28+
'first_name' => '',
29+
'last_name' => ''
3130
end
3231
end
3332

test/models/code_schools_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def setup
66
end
77

88
test 'is_partner should be present and default to false' do
9-
assert @code_school.is_partner == false
9+
assert_not @code_school.is_partner
1010
end
1111

1212
test 'rep_name should be present' do

test/models/user_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def teardown
4545

4646
some_role = create :role
4747
user.update! role_id: some_role.id
48-
assert user.role == some_role
48+
assert_equal some_role, user.role
4949
end
5050

5151
test 'doesnt geocode until we validate' do
@@ -75,11 +75,11 @@ def teardown
7575
test 'validates the presence of a zip' do
7676
user = build :user, zip: nil
7777
refute user.valid?
78-
assert user.errors.full_messages == ["Zip can't be blank"]
78+
assert_equal ["Zip can't be blank"], user.errors.full_messages
7979

8080
user = build :user, zip: ''
8181
refute user.valid?
82-
assert user.errors.full_messages == ["Zip can't be blank"]
82+
assert ["Zip can't be blank"], user.errors.full_messages
8383
end
8484

8585
test 'longitude and longitude are nil for unknown zipcodes' do

test/requests/airtable/mentorship_test.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def setup
88
end
99

1010
def test_mentor_request_data_returns_correct_keys
11-
assert @successful_response.keys.sort == %i[mentors services skillsets]
11+
assert_equal %i[mentors services skillsets], @successful_response.keys.sort
1212
end
1313

1414
def test_mentor_request_data_returns_correct_mentor_data
@@ -54,25 +54,25 @@ def test_create_mentor_request_creates_the_passed_mentor_request
5454
response = Airtable::Mentorship.new.create_mentor_request(request_body)
5555

5656
assert response['id'].present?
57-
assert response.dig('fields', 'Slack User') == request_body[:slack_user]
58-
assert response.dig('fields', 'Email') == request_body[:email]
59-
assert response.dig('fields', 'Service') == [request_body[:services]]
60-
assert response.dig('fields', 'Skillsets') == [request_body[:skillsets]]
61-
assert response.dig('fields', 'Additional Details') == request_body[:additional_details]
62-
assert response.dig('fields', 'Mentor Requested') == [request_body[:mentor_requested]]
57+
assert_equal request_body[:slack_user], response.dig('fields', 'Slack User')
58+
assert_equal request_body[:email], response.dig('fields', 'Email')
59+
assert_equal [request_body[:services]], response.dig('fields', 'Service')
60+
assert_equal [request_body[:skillsets]], response.dig('fields', 'Skillsets')
61+
assert_equal request_body[:additional_details], response.dig('fields', 'Additional Details')
62+
assert_equal [request_body[:mentor_requested]], response.dig('fields', 'Mentor Requested')
6363
end
6464
end
6565

6666
def test_format_for_posting_converts_comma_separated_string_into_array_of_strings
6767
instance = Airtable::Mentorship.new
6868

6969
converted = instance.send(:format_for_posting, 'this , and long ')
70-
assert converted == ['this', 'and long']
70+
assert_equal ['this', 'and long'], converted
7171

7272
converted = instance.send(:format_for_posting, 'this,that')
73-
assert converted == ['this', 'that']
73+
assert_equal ['this', 'that'], converted
7474

7575
converted = instance.send(:format_for_posting, 'this')
76-
assert converted == ['this']
76+
assert_equal ['this'], converted
7777
end
7878
end

0 commit comments

Comments
 (0)