Skip to content

Commit

Permalink
Bug fix, allow allowable periods to be case insensitive (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuenmichelle1 authored Oct 17, 2024
1 parent cef6509 commit 69658b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def validate_date(date_param)
end

def validate_period
raise ValidationError, 'Invalid bucket option. Valid options for period is day, week, month, or year' unless SelectableWithTimeBucket::TIME_BUCKET_OPTIONS.keys.include? params[:period].downcase.to_sym
params[:period] = params[:period].downcase
raise ValidationError, 'Invalid bucket option. Valid options for period is day, week, month, or year' unless SelectableWithTimeBucket::TIME_BUCKET_OPTIONS.keys.include? params[:period].to_sym
end

def valid_date_range
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
end

context 'param validations' do
before(:each) { authenticate!(is_panoptes_admin: true) }
it_behaves_like 'ensure valid query params', :query, id: 1

it 'ensures you cannot query by workflow and project_contributions' do
Expand Down
6 changes: 6 additions & 0 deletions spec/support/query_params_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
expect(response.body).to include('Invalid bucket option. Valid options for period is day, week, month, or year')
end

it 'allows period param to be case-insensitive' do
params[:period] = 'MONTH'
get query, params: params
expect(response.status).to eq(200)
end

it 'ensures that we do not query by both workflow and project' do
params[:workflow_id] = 1
params[:project_id] = 2
Expand Down

0 comments on commit 69658b4

Please sign in to comment.