Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: 2.1

commands:
setup_db:
steps:
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Database setup
command: bundle exec rake db:create && bundle exec rails db:schema:load --trace

orbs:
ruby: circleci/ruby@2.0.0
gitleaks: upenn-libraries/gitleaks@1.0.0

ruby_env_defaults: &ruby_env_defaults
RAILS_ENV: test
RACK_ENV: test
DATABASE_URL: "postgresql://postgres@localhost:5432/ethel-test"
postgres_env_defaults: &postgres_env_defaults
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_DB: ethel-test
POSTGRES_HOST_AUTH_METHOD: trust

jobs:
rspec:
docker:
- image: cimg/ruby:3.2.2
- image: cimg/postgres:14.6
- image: cimg/redis:6.2
environment:
<<: *ruby_env_defaults
<<: *postgres_env_defaults
steps:
- checkout
- ruby/install-deps
- setup_db
- ruby/rspec-test

rubocop:
docker:
- image: cimg/ruby:3.2.2
steps:
- checkout
- ruby/install-deps
- ruby/rubocop-check

workflows:
version: 2
test:
jobs:
- rspec
- rubocop
- gitleaks/check_local:
image: "quay.io/upennlibraries/gitleaks:v1.23.0"
options: "--redact --repo-config"
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ Style/Documentation:
Metrics/ClassLength:
Enabled: false

Metrics/LineLength:
Enabled: false

Metrics/ModuleLength:
Enabled: false

Layout/IndentArray:
Enabled: false

Layout/IndentHash:
Enabled: false

Layout/LineLength:
Enabled: false

Expand Down
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ group :development, :test do
gem 'factory_bot_rails', '~> 6.2'
gem 'pry'
gem 'rspec-rails', '~> 6.0'
end

group :development do
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
gem 'rubocop-discourse', '~> 3.2'
gem 'rubocop-rails', '~> 2.19'
gem "rspec_junit_formatter", "~> 0.6.0"
end


gem "active_model_serializers", "~> 0.10.13"
24 changes: 24 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.10.13)
actionpack (>= 4.1, < 7.1)
activemodel (>= 4.1, < 7.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.3.6)
Expand All @@ -72,6 +77,8 @@ GEM
bootsnap (1.16.0)
msgpack (~> 1.2)
builder (3.2.4)
case_transform (0.2)
activesupport
coderay (1.1.3)
concurrent-ruby (1.2.2)
crass (1.0.6)
Expand Down Expand Up @@ -144,6 +151,7 @@ GEM
irb (1.6.4)
reline (>= 0.3.0)
json (2.6.3)
jsonapi-renderer (0.2.2)
jwt (2.7.0)
loofah (2.21.1)
crass (~> 1.0.2)
Expand Down Expand Up @@ -246,6 +254,8 @@ GEM
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.0)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.50.2)
json (~> 2.3)
parallel (~> 1.10)
Expand All @@ -258,10 +268,21 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.1)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop (~> 1.41)
rubocop-discourse (3.2.0)
rubocop (>= 1.1.0)
rubocop-rspec (>= 2.0.0)
rubocop-factory_bot (2.22.0)
rubocop (~> 1.33)
rubocop-rails (2.19.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rspec (2.22.0)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
signet (0.17.0)
Expand All @@ -287,6 +308,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
active_model_serializers (~> 0.10.13)
bootsnap
debug
factory_bot_rails (~> 6.2)
Expand All @@ -297,6 +319,8 @@ DEPENDENCIES
rack-cors
rails (~> 7.0.4, >= 7.0.4.3)
rspec-rails (~> 6.0)
rspec_junit_formatter (~> 0.6.0)
rubocop-discourse (~> 3.2)
rubocop-rails (~> 2.19)
tzinfo-data

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ItemsController < ApplicationController
def index
permitted_params = params.permit(:year, :item_number, :item_text, :points, :rating)
permitted_params = params.permit(:year, :item_number, :item_text, :points, :rating).reject{|_, v| v.blank?}
render json: Item.filter_by_params(permitted_params)
end
end
3 changes: 3 additions & 0 deletions app/serializers/item_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ItemSerializer < ActiveModel::Serializer
attributes :id, :year, :item_number, :item_number_addendum, :original_item, :spellchecked_item, :special_event, :points, :point_value, :rating, :comment, :errata
end
1 change: 1 addition & 0 deletions config/initializers/serializers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ActiveModelSerializers.config.key_transform = :camel_lower