Skip to content

Commit 85ceaa3

Browse files
author
Ignacio Jonas
committedJun 23, 2016
Add spec for log method to validate the log_id
1 parent deb193b commit 85ceaa3

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed
 

‎.rubocop_todo.yml

-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ Metrics/MethodLength:
33

44
Metrics/LineLength:
55
Max: 121
6-
7-
Metrics/AbcSize:
8-
Max: 15.5

‎lib/auth0/api/v2/logs.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
12
module Auth0
23
module Api
34
module V2
@@ -33,7 +34,10 @@ def logs(options = {})
3334
take: options.fetch(:take, nil)
3435
}
3536
if request_params[:take].to_i > 100
36-
fail Auth0::MissingParameter, 'The total amount of entries should be less than 100'
37+
fail Auth0::MissingParameter, 'The total amount of entries to retrieve should be less than 100'
38+
end
39+
if request_params[:per_page].to_i > 100
40+
fail Auth0::MissingParameter, 'The total amount of entries per page should be less than 100'
3741
end
3842
get(logs_path, request_params)
3943
end

‎spec/lib/auth0/api/v2/logs_spec.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
expect { @instance.logs }.not_to raise_error
2525
end
2626
it 'is expect to rise an error when take is higher than 100' do
27-
expect(@instance.logs(take: rand(101...1000))).to raise_error(
28-
'The total amount of entries should be less than 100')
27+
expect { @instance.logs(take: rand(101..2000)) }.to raise_error(
28+
'The total amount of entries to retrieve should be less than 100')
29+
end
30+
it 'is expect to rise an error when per_page is higher than 100' do
31+
expect { @instance.logs(per_page: rand(101..2000)) }.to raise_error(
32+
'The total amount of entries per page should be less than 100')
2933
end
3034
end
3135

@@ -36,5 +40,6 @@
3640
expect(@instance).to receive(:get).with('/api/v2/logs/LOG_ID')
3741
expect { @instance.log('LOG_ID') }.not_to raise_error
3842
end
43+
it { expect { @instance.log(nil) }.to raise_error('Must supply a valid log_id') }
3944
end
4045
end

0 commit comments

Comments
 (0)
Please sign in to comment.