Skip to content

Commit 21392af

Browse files
authored
lint a random file (#5086)
1 parent da56858 commit 21392af

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed
Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
1+
# frozen_string_literal: true
2+
13
require 'test_helper'
24
require 'net/http'
35

46
class BalanceTest < ActiveSupport::TestCase
57
setup do
68
@balance_defaults = {
7-
user: "ood",
8-
project: "ood-group",
9-
value: 0,
10-
unit: "RU",
9+
user: 'ood',
10+
project: 'ood-group',
11+
value: 0,
12+
unit: 'RU',
1113
updated_at: Time.now
1214
}
1315
end
1416

15-
test "creating files balance instance for a fileset path" do
17+
test 'creating files balance instance for a fileset path' do
1618
balance = Balance.new(@balance_defaults)
1719

18-
assert_equal "ood-group", balance.balance_object
20+
assert_equal 'ood-group', balance.balance_object
1921
refute balance.sufficient?
2022
assert balance.insufficient?
2123
refute balance.sufficient?(threshold: 5)
22-
assert_equal "RU balance is 0", balance.to_s
24+
assert_equal 'RU balance is 0', balance.to_s
2325
end
2426

25-
test "creating files balance instance for a fileset path without project" do
27+
test 'creating files balance instance for a fileset path without project' do
2628
@balance_defaults.delete(:project)
2729
balance = Balance.new(@balance_defaults)
2830

29-
assert_equal "ood", balance.balance_object
31+
assert_equal 'ood', balance.balance_object
3032
refute balance.sufficient?
3133
assert balance.insufficient?
3234
refute balance.sufficient?(threshold: 5)
33-
assert_equal "RU balance is 0", balance.to_s
35+
assert_equal 'RU balance is 0', balance.to_s
3436
end
3537

36-
test "invalid version handles InvalidBalanceFile exception" do
38+
test 'invalid version handles InvalidBalanceFile exception' do
3739
Dir.mktmpdir do |dir|
3840
balance_file = Pathname.new(dir).join('balance.json')
3941
balance_file.write('{"version": 2000}')
@@ -43,7 +45,7 @@ class BalanceTest < ActiveSupport::TestCase
4345
end
4446
end
4547

46-
test "handles InvalidBalanceFile exception for invalid json" do
48+
test 'handles InvalidBalanceFile exception for invalid json' do
4749
Dir.mktmpdir do |dir|
4850
balance_file = Pathname.new(dir).join('balance.json')
4951
balance_file.write('{}')
@@ -53,7 +55,7 @@ class BalanceTest < ActiveSupport::TestCase
5355
end
5456
end
5557

56-
test "handles InvalidBalanceFile exception for json with missing balances array " do
58+
test 'handles InvalidBalanceFile exception for json with missing balances array ' do
5759
Dir.mktmpdir do |dir|
5860
balance_file = Pathname.new(dir).join('balance.json')
5961
balance_file.write('{"version": 1}')
@@ -63,7 +65,7 @@ class BalanceTest < ActiveSupport::TestCase
6365
end
6466
end
6567

66-
test "handles InvalidBalanceFile exception for json array" do
68+
test 'handles InvalidBalanceFile exception for json array' do
6769
Dir.mktmpdir do |dir|
6870
balance_file = Pathname.new(dir).join('balance.json')
6971
balance_file.write('[]')
@@ -73,7 +75,7 @@ class BalanceTest < ActiveSupport::TestCase
7375
end
7476
end
7577

76-
test "handles KeyError for balance with missing path" do
78+
test 'handles KeyError for balance with missing path' do
7779
Dir.mktmpdir do |dir|
7880
balance_file = Pathname.new(dir).join('balance.json')
7981
balance_file.write('{"version": 1, "balances": [ { "user":"ood" }]}')
@@ -82,40 +84,40 @@ class BalanceTest < ActiveSupport::TestCase
8284
end
8385
end
8486

85-
test "loading fixtures from file" do
87+
test 'loading fixtures from file' do
8688
balance_file = Pathname.new "#{Rails.root}/test/fixtures/balance.json"
8789
balances = Balance.find(balance_file, 'tdockendorf')
8890

8991
assert_equal 1, balances.count
9092
assert_equal 0, balances.first.value
9193
end
9294

93-
test "loading fixtures from URL" do
95+
test 'loading fixtures from URL' do
9496
balance_file = Pathname.new("#{Rails.root}/test/fixtures/balance.json").read
9597
# stub open with an object you can call read on
9698
Net::HTTP.stubs(:get).returns(balance_file)
97-
balances = Balance.find("https://url/to/balance.json", 'tdockendorf')
99+
balances = Balance.find('https://url/to/balance.json', 'tdockendorf')
98100

99101
assert_equal 1, balances.count
100102
assert_equal 0, balances.first.value
101103
end
102104

103-
test "handle error loading URL" do
104-
Net::HTTP.stubs(:get).raises(StandardError, "404 file not found")
105-
balances = Balance.find("https://url/to/balance.json", 'tdockendorf')
105+
test 'handle error loading URL' do
106+
Net::HTTP.stubs(:get).raises(StandardError, '404 file not found')
107+
balances = Balance.find('https://url/to/balance.json', 'tdockendorf')
106108

107-
assert_equal [], balances, "Should have handled exception and returned 0 balances"
109+
assert_equal [], balances, 'Should have handled exception and returned 0 balances'
108110
end
109111

110-
test "per balance timestamp" do
112+
test 'per balance timestamp' do
111113
balance_file = Pathname.new "#{Rails.root}/test/fixtures/balance.json"
112114

113115
# per balance timestamp
114116
balances = Balance.find(balance_file, 'djohnson')
115-
assert_equal 1567190705, balances.first.updated_at.to_i
117+
assert_equal 1_567_190_705, balances.first.updated_at.to_i
116118

117119
# global timestamp
118120
balances = Balance.find(balance_file, 'efranz')
119-
assert_equal 1567190705, balances.first.updated_at.to_i
121+
assert_equal 1_567_190_705, balances.first.updated_at.to_i
120122
end
121123
end

0 commit comments

Comments
 (0)