freckle_io 0.1.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -5
- data/freckle-io.gemspec +3 -3
- data/lib/freckle_io/client/entries.rb +1 -26
- data/lib/freckle_io/client/project_groups.rb +0 -2
- data/lib/freckle_io/client/projects.rb +1 -13
- data/lib/freckle_io/client/tags.rb +1 -6
- data/lib/freckle_io/client/users.rb +1 -6
- data/lib/freckle_io/configuration.rb +5 -5
- data/lib/freckle_io/connection.rb +1 -3
- data/lib/freckle_io/params.rb +5 -10
- data/lib/freckle_io/request/multiple_pages.rb +3 -3
- data/lib/freckle_io/request/single_page.rb +2 -2
- data/lib/freckle_io/validator/base_contract.rb +16 -0
- data/lib/freckle_io/validator/entry.rb +26 -50
- data/lib/freckle_io/validator/project.rb +13 -39
- data/lib/freckle_io/validator/project_group.rb +5 -24
- data/lib/freckle_io/validator/tag.rb +5 -24
- data/lib/freckle_io/validator/user.rb +13 -37
- data/lib/freckle_io/validator/validation.yml +8 -13
- data/lib/freckle_io.rb +1 -1
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/_all/returns_a_entry_for_each_response.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/with_unknow_params/doesn_t_raise_a_invalid_params_error.yml +53 -0
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/with_validator/call_entry_s_validator.yml +24 -19
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +261 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/_all/returns_a_project_group_for_each_response.yml +262 -36
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/with_unknow_params/doesn_t_raises_a_invalid_params_error.yml +325 -0
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/with_validator/call_project_group_s_validator.yml +261 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +501 -225
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_all/returns_a_project_for_each_response.yml +501 -225
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_show/get_a_spacific_project.yml +24 -19
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_show/raw_links_should_be_a_empty_array.yml +24 -19
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/with_unknow_params/doesn_t_raises_a_invalid_params_error.yml +865 -0
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/with_validator/call_project_s_validator.yml +502 -226
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/_all/returns_a_tag_for_each_response.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/with_unknow_params/doesn_t_raise_a_invalid_params_error.yml +53 -0
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/with_validator/call_tag_s_validator.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/_all/returns_a_user_for_each_response.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/with_unknow_params/doesn_t_raise_a_invalid_params_error.yml +109 -0
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
- data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/with_validator/call_user_s_validator.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_a_valid_response/must_be_a_json_format.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_freckle_token_authentication/set_X-FreckleToken.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_header/set_user_agent.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_invalid_url/raises_a_resource_not_found_error_for_invalid_resource.yml +13 -16
- data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_page_param/response_must_be_success.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_per_page_param/response_must_have_per_page_elements.yml +24 -19
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_configuration/_get/returns_an_array_of_faraday_response.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_configuration/_get/returns_freckle_default_per_page_elements.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_per_page/_get/return_per_page_number_elements.yml +74 -59
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/next_page_should_be_a_SinglePage.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/prev_page_should_be_nil.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/when_get_last_page_from_the_first_page/next_should_be_nil.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_get/returns_correct_raw_links_for_the_first_page.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/next_page_should_be_nil.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/returns_correct_raw_links_for_the_last_page.yml +45 -35
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/when_get_prev_page_from_the_last_page/prev_should_be_nil.yml +67 -52
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_next/previous_page_is_a_SinglePage.yml +67 -52
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_next/previous_page_should_be_not_nil.yml +67 -52
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_prev/next_page_is_a_SinglePage.yml +89 -69
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_prev/when_get_prev_page_from_the_first_page/prev_should_be_nil.yml +67 -52
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_total_page/with_first_page/returns_the_range_of_pages.yml +23 -18
- data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_total_page/with_next_page/returns_an_empty_array.yml +45 -35
- data/spec/freckle_io/client/entries_spec.rb +23 -32
- data/spec/freckle_io/client/project_groups_spec.rb +11 -20
- data/spec/freckle_io/client/projects_spec.rb +15 -21
- data/spec/freckle_io/client/tags_spec.rb +10 -19
- data/spec/freckle_io/client/users_spec.rb +13 -21
- data/spec/freckle_io/configuration_spec.rb +7 -4
- data/spec/freckle_io/connection_spec.rb +1 -1
- data/spec/freckle_io/paginator_spec.rb +8 -8
- data/spec/freckle_io/params_spec.rb +1 -1
- data/spec/freckle_io/request/single_page_spec.rb +6 -6
- data/spec/spec_helper.rb +3 -3
- data/spec/support/anonymize/entries.rb +9 -8
- data/spec/support/anonymize/project_groups.rb +4 -3
- data/spec/support/anonymize/projects.rb +9 -8
- data/spec/support/anonymize/tags.rb +5 -4
- data/spec/support/anonymize/users.rb +13 -15
- data/spec/support/anonymize_interaction.rb +5 -5
- metadata +29 -24
- data/lib/freckle_io/validator/restricted_hash.rb +0 -11
|
@@ -73,25 +73,23 @@ describe FreckleIO::Client::Entries do
|
|
|
73
73
|
{
|
|
74
74
|
invalid_params: "oh! oh!",
|
|
75
75
|
updated_from: "2018-01-15T00:00:00Z",
|
|
76
|
-
updated_to: "2018-01-
|
|
76
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
77
77
|
}
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
let(:results) { subject.all(params) }
|
|
81
81
|
|
|
82
|
-
it "
|
|
83
|
-
expect
|
|
84
|
-
results
|
|
85
|
-
end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
|
|
82
|
+
it "doesn't raise a invalid params error" do
|
|
83
|
+
expect { results }.not_to raise_error
|
|
86
84
|
end
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
describe "with wrong user ids" do
|
|
90
88
|
let(:params) do
|
|
91
89
|
{
|
|
92
|
-
|
|
90
|
+
user_ids: 1234,
|
|
93
91
|
updated_from: "2018-01-15T00:00:00Z",
|
|
94
|
-
updated_to: "2018-01-
|
|
92
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
95
93
|
}
|
|
96
94
|
end
|
|
97
95
|
|
|
@@ -109,7 +107,7 @@ describe FreckleIO::Client::Entries do
|
|
|
109
107
|
{
|
|
110
108
|
description: 1234,
|
|
111
109
|
updated_from: "2018-01-15T00:00:00Z",
|
|
112
|
-
updated_to: "2018-01-
|
|
110
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
113
111
|
}
|
|
114
112
|
end
|
|
115
113
|
|
|
@@ -127,7 +125,7 @@ describe FreckleIO::Client::Entries do
|
|
|
127
125
|
{
|
|
128
126
|
project_ids: 123,
|
|
129
127
|
updated_from: "2018-01-15T00:00:00Z",
|
|
130
|
-
updated_to: "2018-01-
|
|
128
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
131
129
|
}
|
|
132
130
|
end
|
|
133
131
|
|
|
@@ -145,7 +143,7 @@ describe FreckleIO::Client::Entries do
|
|
|
145
143
|
{
|
|
146
144
|
tag_ids: 12,
|
|
147
145
|
updated_from: "2018-01-15T00:00:00Z",
|
|
148
|
-
updated_to: "2018-01-
|
|
146
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
149
147
|
}
|
|
150
148
|
end
|
|
151
149
|
|
|
@@ -163,7 +161,7 @@ describe FreckleIO::Client::Entries do
|
|
|
163
161
|
{
|
|
164
162
|
tag_filter_type: "or",
|
|
165
163
|
updated_from: "2018-01-15T00:00:00Z",
|
|
166
|
-
updated_to: "2018-01-
|
|
164
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
167
165
|
}
|
|
168
166
|
end
|
|
169
167
|
|
|
@@ -199,7 +197,7 @@ describe FreckleIO::Client::Entries do
|
|
|
199
197
|
{
|
|
200
198
|
to: 123,
|
|
201
199
|
updated_from: "2018-01-15T00:00:00Z",
|
|
202
|
-
updated_to: "2018-01-
|
|
200
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
203
201
|
}
|
|
204
202
|
end
|
|
205
203
|
|
|
@@ -247,9 +245,9 @@ describe FreckleIO::Client::Entries do
|
|
|
247
245
|
describe "with wrong billable" do
|
|
248
246
|
let(:params) do
|
|
249
247
|
{
|
|
250
|
-
|
|
248
|
+
billable: 123,
|
|
251
249
|
updated_from: "2018-01-15T00:00:00Z",
|
|
252
|
-
updated_to: "2018-01-
|
|
250
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
253
251
|
}
|
|
254
252
|
end
|
|
255
253
|
|
|
@@ -267,7 +265,7 @@ describe FreckleIO::Client::Entries do
|
|
|
267
265
|
{
|
|
268
266
|
approved_at_from: 123,
|
|
269
267
|
updated_from: "2018-01-15T00:00:00Z",
|
|
270
|
-
updated_to: "2018-01-
|
|
268
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
271
269
|
}
|
|
272
270
|
end
|
|
273
271
|
|
|
@@ -285,7 +283,7 @@ describe FreckleIO::Client::Entries do
|
|
|
285
283
|
{
|
|
286
284
|
approved_at_to: 123,
|
|
287
285
|
updated_from: "2018-01-15T00:00:00Z",
|
|
288
|
-
updated_to: "2018-01-
|
|
286
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
289
287
|
}
|
|
290
288
|
end
|
|
291
289
|
|
|
@@ -303,7 +301,7 @@ describe FreckleIO::Client::Entries do
|
|
|
303
301
|
{
|
|
304
302
|
approved_by_ids: 123,
|
|
305
303
|
updated_from: "2018-01-15T00:00:00Z",
|
|
306
|
-
updated_to: "2018-01-
|
|
304
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
307
305
|
}
|
|
308
306
|
end
|
|
309
307
|
|
|
@@ -318,17 +316,16 @@ describe FreckleIO::Client::Entries do
|
|
|
318
316
|
|
|
319
317
|
describe "with validator" do
|
|
320
318
|
let(:entry_validator) do
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
)
|
|
319
|
+
instance_double(FreckleIO::Validator::Entry)
|
|
320
|
+
end
|
|
321
|
+
let(:validation_result) do
|
|
322
|
+
instance_double(Dry::Validation::Result, errors: {}, to_h: params)
|
|
326
323
|
end
|
|
327
324
|
|
|
328
325
|
let(:params) do
|
|
329
326
|
{
|
|
330
327
|
updated_from: "2018-01-15T00:00:00Z",
|
|
331
|
-
updated_to: "2018-01-
|
|
328
|
+
updated_to: "2018-01-15T00:00:00Z"
|
|
332
329
|
}
|
|
333
330
|
end
|
|
334
331
|
|
|
@@ -337,22 +334,16 @@ describe FreckleIO::Client::Entries do
|
|
|
337
334
|
end
|
|
338
335
|
|
|
339
336
|
before do
|
|
340
|
-
allow(FreckleIO::Validator::Entry).to receive(
|
|
341
|
-
:validation
|
|
342
|
-
).with(params, FreckleIO::Client::Entries::ALLOWED_KEYS) do
|
|
337
|
+
allow(FreckleIO::Validator::Entry).to receive(:new) do
|
|
343
338
|
entry_validator
|
|
344
339
|
end
|
|
345
|
-
|
|
346
|
-
allow(FreckleIO::Validator::Entry).to receive(:errors)
|
|
347
|
-
allow(FreckleIO::Validator::Entry).to receive(:output)
|
|
340
|
+
allow(entry_validator).to receive(:call) { validation_result }
|
|
348
341
|
|
|
349
342
|
result
|
|
350
343
|
end
|
|
351
344
|
|
|
352
345
|
it "call entry's validator" do
|
|
353
|
-
expect(
|
|
354
|
-
:validation
|
|
355
|
-
)
|
|
346
|
+
expect(entry_validator).to have_received(:call)
|
|
356
347
|
end
|
|
357
348
|
end
|
|
358
349
|
end
|
|
@@ -57,10 +57,8 @@ describe FreckleIO::Client::ProjectGroups do
|
|
|
57
57
|
|
|
58
58
|
let(:results) { subject.all(params) }
|
|
59
59
|
|
|
60
|
-
it "raises a invalid params error" do
|
|
61
|
-
expect
|
|
62
|
-
results
|
|
63
|
-
end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
|
|
60
|
+
it "doesn't raises a invalid params error" do
|
|
61
|
+
expect { results }.not_to raise_error
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
|
|
@@ -80,10 +78,10 @@ describe FreckleIO::Client::ProjectGroups do
|
|
|
80
78
|
end
|
|
81
79
|
end
|
|
82
80
|
|
|
83
|
-
describe "with project ids" do
|
|
81
|
+
describe "with wrong project ids" do
|
|
84
82
|
let(:params) do
|
|
85
83
|
{
|
|
86
|
-
|
|
84
|
+
project_ids: 123
|
|
87
85
|
}
|
|
88
86
|
end
|
|
89
87
|
|
|
@@ -98,11 +96,10 @@ describe FreckleIO::Client::ProjectGroups do
|
|
|
98
96
|
|
|
99
97
|
describe "with validator" do
|
|
100
98
|
let(:project_group_validator) do
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
)
|
|
99
|
+
instance_double(FreckleIO::Validator::ProjectGroup)
|
|
100
|
+
end
|
|
101
|
+
let(:validation_result) do
|
|
102
|
+
instance_double(Dry::Validation::Result, errors: {}, to_h: {})
|
|
106
103
|
end
|
|
107
104
|
|
|
108
105
|
let(:result) do
|
|
@@ -110,22 +107,16 @@ describe FreckleIO::Client::ProjectGroups do
|
|
|
110
107
|
end
|
|
111
108
|
|
|
112
109
|
before do
|
|
113
|
-
allow(FreckleIO::Validator::ProjectGroup).to receive(
|
|
114
|
-
:validation
|
|
115
|
-
).with({}, FreckleIO::Client::ProjectGroups::ALLOWED_KEYS) do
|
|
110
|
+
allow(FreckleIO::Validator::ProjectGroup).to receive(:new) do
|
|
116
111
|
project_group_validator
|
|
117
112
|
end
|
|
118
|
-
|
|
119
|
-
allow(FreckleIO::Validator::ProjectGroup).to receive(:errors)
|
|
120
|
-
allow(FreckleIO::Validator::ProjectGroup).to receive(:output)
|
|
113
|
+
allow(project_group_validator).to receive(:call) { validation_result }
|
|
121
114
|
|
|
122
115
|
result
|
|
123
116
|
end
|
|
124
117
|
|
|
125
118
|
it "call project group's validator" do
|
|
126
|
-
expect(
|
|
127
|
-
:validation
|
|
128
|
-
)
|
|
119
|
+
expect(project_group_validator).to have_received(:call)
|
|
129
120
|
end
|
|
130
121
|
end
|
|
131
122
|
end
|
|
@@ -18,7 +18,10 @@ describe FreckleIO::Client::Projects do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
describe "#show" do
|
|
21
|
-
let(:
|
|
21
|
+
let(:real_freckle_project_id) do
|
|
22
|
+
ENV.fetch("REAL_FRECKLE_PROJECT_ID", nil)
|
|
23
|
+
end
|
|
24
|
+
let(:result) { subject.show(real_freckle_project_id) }
|
|
22
25
|
let(:response) { result.last_response }
|
|
23
26
|
|
|
24
27
|
it "get a spacific project" do
|
|
@@ -60,17 +63,15 @@ describe FreckleIO::Client::Projects do
|
|
|
60
63
|
|
|
61
64
|
let(:results) { subject.all(params) }
|
|
62
65
|
|
|
63
|
-
it "raises a invalid params error" do
|
|
64
|
-
expect
|
|
65
|
-
results
|
|
66
|
-
end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
|
|
66
|
+
it "doesn't raises a invalid params error" do
|
|
67
|
+
expect { results }.not_to raise_error
|
|
67
68
|
end
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
describe "with wrong name" do
|
|
71
72
|
let(:params) do
|
|
72
73
|
{
|
|
73
|
-
|
|
74
|
+
name: ""
|
|
74
75
|
}
|
|
75
76
|
end
|
|
76
77
|
|
|
@@ -102,7 +103,7 @@ describe FreckleIO::Client::Projects do
|
|
|
102
103
|
describe "with wrong billing increment" do
|
|
103
104
|
let(:params) do
|
|
104
105
|
{
|
|
105
|
-
billing_increment: "
|
|
106
|
+
billing_increment: "3"
|
|
106
107
|
}
|
|
107
108
|
end
|
|
108
109
|
|
|
@@ -149,11 +150,10 @@ describe FreckleIO::Client::Projects do
|
|
|
149
150
|
|
|
150
151
|
describe "with validator" do
|
|
151
152
|
let(:project_validator) do
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
)
|
|
153
|
+
instance_double(FreckleIO::Validator::Project)
|
|
154
|
+
end
|
|
155
|
+
let(:validation_result) do
|
|
156
|
+
instance_double(Dry::Validation::Result, errors: {}, to_h: {})
|
|
157
157
|
end
|
|
158
158
|
|
|
159
159
|
let(:result) do
|
|
@@ -161,22 +161,16 @@ describe FreckleIO::Client::Projects do
|
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
before do
|
|
164
|
-
allow(FreckleIO::Validator::Project).to receive(
|
|
165
|
-
:validation
|
|
166
|
-
).with({}, FreckleIO::Client::Projects::ALLOWED_KEYS) do
|
|
164
|
+
allow(FreckleIO::Validator::Project).to receive(:new) do
|
|
167
165
|
project_validator
|
|
168
166
|
end
|
|
169
|
-
|
|
170
|
-
allow(FreckleIO::Validator::Project).to receive(:errors)
|
|
171
|
-
allow(FreckleIO::Validator::Project).to receive(:output)
|
|
167
|
+
allow(project_validator).to receive(:call) { validation_result }
|
|
172
168
|
|
|
173
169
|
result
|
|
174
170
|
end
|
|
175
171
|
|
|
176
172
|
it "call project's validator" do
|
|
177
|
-
expect(
|
|
178
|
-
:validation
|
|
179
|
-
)
|
|
173
|
+
expect(project_validator).to have_received(:call)
|
|
180
174
|
end
|
|
181
175
|
end
|
|
182
176
|
end
|
|
@@ -57,10 +57,8 @@ describe FreckleIO::Client::Tags do
|
|
|
57
57
|
|
|
58
58
|
let(:results) { subject.all(params) }
|
|
59
59
|
|
|
60
|
-
it "
|
|
61
|
-
expect
|
|
62
|
-
results
|
|
63
|
-
end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
|
|
60
|
+
it "doesn't raise a invalid params error" do
|
|
61
|
+
expect { results }.not_to raise_error
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
|
|
@@ -83,7 +81,7 @@ describe FreckleIO::Client::Tags do
|
|
|
83
81
|
describe "with billable" do
|
|
84
82
|
let(:params) do
|
|
85
83
|
{
|
|
86
|
-
|
|
84
|
+
billable: 123
|
|
87
85
|
}
|
|
88
86
|
end
|
|
89
87
|
|
|
@@ -98,11 +96,10 @@ describe FreckleIO::Client::Tags do
|
|
|
98
96
|
|
|
99
97
|
describe "with validator" do
|
|
100
98
|
let(:tag_validator) do
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
)
|
|
99
|
+
instance_double(FreckleIO::Validator::Tag)
|
|
100
|
+
end
|
|
101
|
+
let(:validation_result) do
|
|
102
|
+
instance_double(Dry::Validation::Result, errors: {}, to_h: {})
|
|
106
103
|
end
|
|
107
104
|
|
|
108
105
|
let(:result) do
|
|
@@ -110,22 +107,16 @@ describe FreckleIO::Client::Tags do
|
|
|
110
107
|
end
|
|
111
108
|
|
|
112
109
|
before do
|
|
113
|
-
allow(FreckleIO::Validator::Tag).to receive(
|
|
114
|
-
:validation
|
|
115
|
-
).with({}, FreckleIO::Client::Tags::ALLOWED_KEYS) do
|
|
110
|
+
allow(FreckleIO::Validator::Tag).to receive(:new) do
|
|
116
111
|
tag_validator
|
|
117
112
|
end
|
|
118
|
-
|
|
119
|
-
allow(FreckleIO::Validator::Tag).to receive(:errors)
|
|
120
|
-
allow(FreckleIO::Validator::Tag).to receive(:output)
|
|
113
|
+
allow(tag_validator).to receive(:call) { validation_result }
|
|
121
114
|
|
|
122
115
|
result
|
|
123
116
|
end
|
|
124
117
|
|
|
125
118
|
it "call tag's validator" do
|
|
126
|
-
expect(
|
|
127
|
-
:validation
|
|
128
|
-
)
|
|
119
|
+
expect(tag_validator).to have_received(:call)
|
|
129
120
|
end
|
|
130
121
|
end
|
|
131
122
|
end
|
|
@@ -18,7 +18,10 @@ describe FreckleIO::Client::Users do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
describe "#show" do
|
|
21
|
-
let(:
|
|
21
|
+
let(:real_freckle_user_id) do
|
|
22
|
+
ENV.fetch("REAL_FRECKLE_USER_ID", nil)
|
|
23
|
+
end
|
|
24
|
+
let(:result) { subject.show(real_freckle_user_id) }
|
|
22
25
|
let(:response) { result.last_response }
|
|
23
26
|
|
|
24
27
|
it "get a spacific user" do
|
|
@@ -59,10 +62,8 @@ describe FreckleIO::Client::Users do
|
|
|
59
62
|
|
|
60
63
|
let(:results) { subject.all(params) }
|
|
61
64
|
|
|
62
|
-
it "
|
|
63
|
-
expect
|
|
64
|
-
results
|
|
65
|
-
end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
|
|
65
|
+
it "doesn't raise a invalid params error" do
|
|
66
|
+
expect { results }.not_to raise_error
|
|
66
67
|
end
|
|
67
68
|
end
|
|
68
69
|
|
|
@@ -116,11 +117,10 @@ describe FreckleIO::Client::Users do
|
|
|
116
117
|
|
|
117
118
|
describe "with validator" do
|
|
118
119
|
let(:user_validator) do
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)
|
|
120
|
+
instance_double(FreckleIO::Validator::User)
|
|
121
|
+
end
|
|
122
|
+
let(:validation_result) do
|
|
123
|
+
instance_double(Dry::Validation::Result, errors: {}, to_h: {})
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
let(:result) do
|
|
@@ -128,22 +128,14 @@ describe FreckleIO::Client::Users do
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
before do
|
|
131
|
-
allow(FreckleIO::Validator::User).to receive(
|
|
132
|
-
|
|
133
|
-
).with({}, FreckleIO::Client::Users::ALLOWED_KEYS) do
|
|
134
|
-
user_validator
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
allow(FreckleIO::Validator::User).to receive(:errors)
|
|
138
|
-
allow(FreckleIO::Validator::User).to receive(:output)
|
|
131
|
+
allow(FreckleIO::Validator::User).to receive(:new) { user_validator }
|
|
132
|
+
allow(user_validator).to receive(:call) { validation_result }
|
|
139
133
|
|
|
140
134
|
result
|
|
141
135
|
end
|
|
142
136
|
|
|
143
137
|
it "call user's validator" do
|
|
144
|
-
expect(
|
|
145
|
-
:validation
|
|
146
|
-
)
|
|
138
|
+
expect(user_validator).to have_received(:call)
|
|
147
139
|
end
|
|
148
140
|
end
|
|
149
141
|
end
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
require_relative "../spec_helper"
|
|
2
2
|
|
|
3
3
|
describe FreckleIO::Configuration do
|
|
4
|
+
let(:freckle_token) { ENV.fetch("FRECKLE_TOKEN", nil) }
|
|
5
|
+
let(:freckle_url) { ENV.fetch("FRECKLE_URL", nil) }
|
|
6
|
+
|
|
4
7
|
context "with right configuration" do
|
|
5
8
|
before do
|
|
6
9
|
FreckleIO.reset
|
|
7
10
|
FreckleIO.configure do |config|
|
|
8
|
-
config.token =
|
|
9
|
-
config.url =
|
|
11
|
+
config.token = freckle_token
|
|
12
|
+
config.url = freckle_url
|
|
10
13
|
end
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
it "return the correct token" do
|
|
14
17
|
expect(
|
|
15
18
|
FreckleIO.configuration.token
|
|
16
|
-
).to eq
|
|
19
|
+
).to eq freckle_token
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
it "return the correct url" do
|
|
20
23
|
expect(
|
|
21
24
|
FreckleIO.configuration.url
|
|
22
|
-
).to eq
|
|
25
|
+
).to eq freckle_url
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
|
|
@@ -52,25 +52,25 @@ describe FreckleIO::Paginator do
|
|
|
52
52
|
|
|
53
53
|
describe "#next" do
|
|
54
54
|
it "return nil" do
|
|
55
|
-
expect(result.next).to
|
|
55
|
+
expect(result.next).to be_nil
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
describe "#prev" do
|
|
60
60
|
it "return nil" do
|
|
61
|
-
expect(result.prev).to
|
|
61
|
+
expect(result.prev).to be_nil
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
describe "#last" do
|
|
66
66
|
it "return nil" do
|
|
67
|
-
expect(result.last).to
|
|
67
|
+
expect(result.last).to be_nil
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
describe "#first" do
|
|
72
72
|
it "return nil" do
|
|
73
|
-
expect(result.first).to
|
|
73
|
+
expect(result.first).to be_nil
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
end
|
|
@@ -80,25 +80,25 @@ describe FreckleIO::Paginator do
|
|
|
80
80
|
|
|
81
81
|
describe "#next" do
|
|
82
82
|
it "return nil" do
|
|
83
|
-
expect(result.next).to
|
|
83
|
+
expect(result.next).to be_nil
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
describe "#prev" do
|
|
88
88
|
it "return nil" do
|
|
89
|
-
expect(result.prev).to
|
|
89
|
+
expect(result.prev).to be_nil
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
describe "#last" do
|
|
94
94
|
it "return nil" do
|
|
95
|
-
expect(result.last).to
|
|
95
|
+
expect(result.last).to be_nil
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
describe "#first" do
|
|
100
100
|
it "return nil" do
|
|
101
|
-
expect(result.first).to
|
|
101
|
+
expect(result.first).to be_nil
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
end
|
|
@@ -17,7 +17,7 @@ describe FreckleIO::Request::SinglePage do
|
|
|
17
17
|
let(:body_response) { next_users.last_response.body }
|
|
18
18
|
|
|
19
19
|
it "previous page should be not nil" do
|
|
20
|
-
expect(next_users.prev).to_not
|
|
20
|
+
expect(next_users.prev).to_not be_nil
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "previous page is a SinglePage" do
|
|
@@ -39,7 +39,7 @@ describe FreckleIO::Request::SinglePage do
|
|
|
39
39
|
|
|
40
40
|
context "when get prev page from the first page" do
|
|
41
41
|
it "prev should be nil" do
|
|
42
|
-
expect(prev_users.prev).to
|
|
42
|
+
expect(prev_users.prev).to be_nil
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -53,7 +53,7 @@ describe FreckleIO::Request::SinglePage do
|
|
|
53
53
|
let(:body_response) { last_users.last_response.body }
|
|
54
54
|
|
|
55
55
|
it "next page should be nil" do
|
|
56
|
-
expect(last_users.next).to
|
|
56
|
+
expect(last_users.next).to be_nil
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "returns correct raw links for the last page" do
|
|
@@ -62,7 +62,7 @@ describe FreckleIO::Request::SinglePage do
|
|
|
62
62
|
|
|
63
63
|
context "when get prev page from the last page" do
|
|
64
64
|
it "prev should be nil" do
|
|
65
|
-
expect(last_users.first.prev).to
|
|
65
|
+
expect(last_users.first.prev).to be_nil
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -72,7 +72,7 @@ describe FreckleIO::Request::SinglePage do
|
|
|
72
72
|
let(:body_response) { first_users.last_response.body }
|
|
73
73
|
|
|
74
74
|
it "prev page should be nil" do
|
|
75
|
-
expect(first_users.prev).to
|
|
75
|
+
expect(first_users.prev).to be_nil
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it "next page should be a SinglePage" do
|
|
@@ -81,7 +81,7 @@ describe FreckleIO::Request::SinglePage do
|
|
|
81
81
|
|
|
82
82
|
context "when get last page from the first page" do
|
|
83
83
|
it "next should be nil" do
|
|
84
|
-
expect(first_users.last.next).to
|
|
84
|
+
expect(first_users.last.next).to be_nil
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -29,16 +29,16 @@ require "dotenv"
|
|
|
29
29
|
Dotenv.load(".env.test")
|
|
30
30
|
|
|
31
31
|
RSpec.configure do |config|
|
|
32
|
-
config.before
|
|
32
|
+
config.before do
|
|
33
33
|
FreckleIO.configure do |c|
|
|
34
|
-
c.token = ENV
|
|
34
|
+
c.token = ENV.fetch("FRECKLE_TOKEN", nil)
|
|
35
35
|
c.auth_type = :freckle_token
|
|
36
36
|
c.max_concurrency = 5
|
|
37
37
|
c.url = "https://api.nokotime.com"
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
config.after
|
|
41
|
+
config.after do
|
|
42
42
|
FreckleIO.reset
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
module Anonymize
|
|
2
2
|
class Entries
|
|
3
3
|
attr_accessor :interaction
|
|
4
|
+
|
|
4
5
|
ENTRY_API_REPLACE_VALUES = {
|
|
5
|
-
id:
|
|
6
|
-
description:
|
|
7
|
-
name:
|
|
8
|
-
email:
|
|
9
|
-
first_name:
|
|
10
|
-
last_name:
|
|
11
|
-
profile_image_url:
|
|
12
|
-
url:
|
|
6
|
+
id: /"id":(.*?),/i,
|
|
7
|
+
description: /"description":"(.*?)"/i,
|
|
8
|
+
name: /"name":"(.*?)"/i,
|
|
9
|
+
email: /"email":"(.*?)",/i,
|
|
10
|
+
first_name: /"first_name":"(.*?)"/i,
|
|
11
|
+
last_name: /"last_name":"(.*?)"/i,
|
|
12
|
+
profile_image_url: /"profile_image_url":"(.*?)"/i,
|
|
13
|
+
url: /"url":"(.*?)"/i
|
|
13
14
|
}.freeze
|
|
14
15
|
|
|
15
16
|
def initialize(interaction:)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
module Anonymize
|
|
2
2
|
class ProjectGroups
|
|
3
3
|
attr_accessor :interaction
|
|
4
|
+
|
|
4
5
|
PROJECT_GROUP_API_REPLACE_VALUES = {
|
|
5
|
-
id:
|
|
6
|
-
name:
|
|
7
|
-
url:
|
|
6
|
+
id: /"id":(.*?),/mi,
|
|
7
|
+
name: /"name":"(.*?)"/mi,
|
|
8
|
+
url: /"url":"(.*?)"/mi
|
|
8
9
|
}.freeze
|
|
9
10
|
|
|
10
11
|
def initialize(interaction:)
|