Skip to content

Commit

Permalink
Merge branch 'develop' into housekeeping/upgrade-puma
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoocasali authored Oct 23, 2020
2 parents 81bad55 + 2535377 commit fafce88
Show file tree
Hide file tree
Showing 34 changed files with 582 additions and 369 deletions.
54 changes: 54 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://docs.rubocop.org/rubocop/configuration

require:
- rubocop-rails
- rubocop-rspec

AllCops:
NewCops: enable
Exclude:
- 'Gemfile'
- '**/*.rake'
- 'bin/**/*'
- 'config/**/*'
- 'db/**/*'
- 'node_modules/**/*'
- 'vendor/**/*'
- 'tmp/**/*'
- 'Rakefile'
- 'config.rb'
- 'config.ru'

Style/Documentation:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Style/StringLiterals:
Enabled: false

Metrics/BlockLength:
ExcludedMethods:
- describe
- context
- factory
- define

RSpec/ExampleLength:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

Style/RegexpLiteral:
AllowInnerSlashes: true
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ before_script:
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- docker-compose run web rubocop
- docker-compose run -e "RAILS_ENV=test" web rake db:test:prepare spec
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT --prefix /refugerestrooms
17 changes: 15 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,27 @@ This is equivalent, but slower during a code-test-code-test development cycle:
docker-compose run web rspec spec/models/restroom_spec.rb
```

### 7 Shut down the Docker Container:
### 7 Linting Code
Ruby code is linted with [rubocop](https://docs.rubocop.org/).

If you want to lint your code before pushing it, you can run:
```
docker-compose run web rubocop
```

Some lint issues can be resolved automatically by running:
```
docker-compose run web rubocop --auto-correct
```

### 8 Shut down the Docker Container:
In another terminal window, run:
```
docker-compose down
```
_(Shutting down the container in this way is safer than exiting with `Ctrl + C`, and prevents issues with breaking the `db` container.)_

### 8 Optional tasks:
### 9 Optional tasks:
To clean up encoding problems in the safe2pee data, run (Use `rake db:fix_accents[dry_run]` to preview the changes.):
```
docker-compose run rake db:fixaccents
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ group :development, :test do
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'pry'
gem 'rspec-rails'
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', require: false
end

group :development do
Expand Down
28 changes: 28 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ GEM
arbre (1.2.1)
activesupport (>= 3.0.0)
arel (9.0.0)
ast (2.4.1)
autoprefixer-rails (9.7.5)
execjs
bcrypt (3.1.13)
Expand Down Expand Up @@ -234,6 +235,9 @@ GEM
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
parallel (1.19.2)
parser (2.7.2.0)
ast (~> 2.4.1)
pg (1.2.3)
pg_search (2.3.2)
activerecord (>= 5.2)
Expand Down Expand Up @@ -285,6 +289,7 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (13.0.1)
rakismet (1.5.4)
ransack (2.3.2)
Expand All @@ -300,6 +305,7 @@ GEM
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.4)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.1)
Expand All @@ -317,6 +323,24 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.2)
rubocop (0.92.0)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.5.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.7.1)
parser (>= 2.7.1.5)
rubocop-rails (2.8.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.87.0)
rubocop-rspec (1.43.2)
rubocop (~> 0.87)
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.2)
ruby_dep (1.5.0)
safe_yaml (1.0.5)
Expand Down Expand Up @@ -360,6 +384,7 @@ GEM
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.7.0)
unicode_utils (1.4.0)
warden (1.2.8)
rack (>= 2.0.6)
Expand Down Expand Up @@ -418,6 +443,9 @@ DEPENDENCIES
rails (= 5.2.4.4)
rakismet
rspec-rails
rubocop
rubocop-rails
rubocop-rspec
sassc-rails
sdoc
simple_form (~> 5.0)
Expand Down
3 changes: 1 addition & 2 deletions app/admin/admin_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
filter :email

form do |f|
f.inputs "Admin Details" do
f.inputs 'Admin Details' do
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end

end
15 changes: 7 additions & 8 deletions app/admin/dashboard.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }

menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }

content :title => proc{ I18n.t("active_admin.dashboard") } do
div :class => "blank_slate_container", :id => "dashboard_default_message" do
span :class => "blank_slate" do
span I18n.t("active_admin.dashboard_welcome.welcome")
small I18n.t("active_admin.dashboard_welcome.call_to_action")
content title: proc { I18n.t('active_admin.dashboard') } do
div class: 'blank_slate_container', id: 'dashboard_default_message' do
span class: 'blank_slate' do
span I18n.t('active_admin.dashboard_welcome.welcome')
small I18n.t('active_admin.dashboard_welcome.call_to_action')
end
end

Expand All @@ -29,5 +28,5 @@
# end
# end
# end
end # content
end
end
5 changes: 2 additions & 3 deletions app/admin/restroom.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ActiveAdmin.register Restroom do

permit_params :name, :street, :city, :state, :accessible, :changing_table, :unisex, :directions,
:comment, :latitude, :longitude, :country, :edit_id, :approved
permit_params :name, :street, :city, :state, :accessible, :changing_table, :unisex, :directions,
:comment, :latitude, :longitude, :country, :edit_id, :approved
end
5 changes: 3 additions & 2 deletions app/controllers/api/docs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Api::DocsController < ApplicationController
def index
module Api
class DocsController < ApplicationController
def index; end
end
end
20 changes: 13 additions & 7 deletions app/controllers/api/v1/restrooms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Restrooms < Grape::API
version 'v1'
format :json

# rubocop:disable Metrics/BlockLength
resource :restrooms do
desc "Get all restroom records ordered by date descending."
params do
Expand Down Expand Up @@ -49,14 +50,18 @@ class Restrooms < Grape::API
r = r.current
r = r.accessible if params[:ada].present?
r = r.unisex if params[:unisex]
paginate(r.near([params[:lat], params[:lng]], 20, :order => 'distance'))
paginate(r.near([params[:lat], params[:lng]], 20, order: 'distance'))
end

desc "Search for restroom records updated or created on or after a given date"
params do
optional :ada, type: Boolean, desc: "Only return restrooms that are ADA accessible."
optional :unisex, type: Boolean, desc: "Only return restrooms that are unisex."
optional :updated, type: Boolean, desc: "Return restroom records updated (rather than created) since given date"
optional(
:updated,
type: Boolean,
desc: "Return restroom records updated (rather than created) since given date"
)
requires :day, type: Integer, desc: "Day"
requires :month, type: Integer, desc: "Month"
requires :year, type: Integer, desc: "Year"
Expand All @@ -65,16 +70,17 @@ class Restrooms < Grape::API
r = Restroom
r = r.current
date = Date.new(params[:year], params[:month], params[:day])
if params[:updated]
r = r.updated_since(date)
else
r = r.created_since(date)
end
r = if params[:updated]
r.updated_since(date)
else
r.created_since(date)
end
r = r.accessible if params[:ada].present?
r = r.unisex if params[:unisex].present?
paginate(r.order(created_at: :desc))
end
end
# rubocop:enable Metrics/BlockLength
end
end
end
7 changes: 3 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ def mobile_filter_header
@mobile = true
end

def set_locale
I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
end

def set_locale
I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
end
end
4 changes: 4 additions & 0 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ def new
@contact = Contact.new(restroom_id: params['restroom_id'], restroom_name: params['restroom_name'])
end

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def create
@contact = Contact.new(params[:contact])
unless @contact.valid?
Expand All @@ -26,4 +28,6 @@ def create
flash.now[:error] = nil
flash.now[:notice] = I18n.t('contacts.submitted.thank-you-exclamation')
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength
end
Loading

0 comments on commit fafce88

Please sign in to comment.