Skip to content

Commit

Permalink
Merge pull request #233 from collectiveidea/upgrade
Browse files Browse the repository at this point in the history
Upgrade to Rails 7.1
  • Loading branch information
danielmorrison authored Jan 9, 2024
2 parents 78bf7b0 + 0972d9d commit 3287ff4
Show file tree
Hide file tree
Showing 21 changed files with 95 additions and 88 deletions.
3 changes: 3 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins:
- standard-performance
- standard-rails
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ group :development, :test do
gem "figaro"
gem "rspec-rails"
gem "standard"
gem "standard-performance"
gem "standard-rails"
end

group :test do
Expand Down
42 changes: 26 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ GEM
cssbundling-rails (1.3.3)
railties (>= 6.0.0)
date (3.3.4)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
debug (1.9.1)
irb (~> 1.10)
reline (>= 0.3.8)
diff-lcs (1.5.0)
erubi (1.12.0)
factory_bot (6.4.5)
Expand Down Expand Up @@ -126,14 +126,14 @@ GEM
honeybadger (5.4.1)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
importmap-rails (1.2.3)
importmap-rails (2.0.1)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.6.0)
irb (1.9.0)
io-console (0.7.1)
irb (1.11.1)
rdoc
reline (>= 0.3.8)
reline (>= 0.4.2)
json (2.7.1)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
Expand All @@ -157,21 +157,21 @@ GEM
minitest (5.20.0)
msgpack (1.7.2)
multipart-post (2.3.0)
net-imap (0.4.5)
net-imap (0.4.9.1)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0)
net-smtp (0.4.0.1)
net-protocol
nio4r (2.7.0)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
parallel (1.24.0)
parser (3.2.2.4)
parser (3.3.0.2)
ast (~> 2.4.1)
racc
particlerb (2.1.0)
Expand All @@ -183,7 +183,7 @@ GEM
activesupport (>= 7.0.0)
rack
railties (>= 7.0.0)
psych (5.1.1.1)
psych (5.1.2)
stringio
puma (6.4.2)
nio4r (~> 2.0)
Expand Down Expand Up @@ -221,10 +221,10 @@ GEM
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.1.0)
rdoc (6.6.0)
rdoc (6.6.2)
psych (>= 4.0.0)
regexp_parser (2.8.3)
reline (0.4.0)
regexp_parser (2.9.0)
reline (0.4.2)
io-console (~> 0.5)
request_store (1.5.1)
rack (>= 1.4)
Expand Down Expand Up @@ -266,9 +266,14 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.20.1)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rails (2.23.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
standard (1.33.0)
Expand All @@ -283,7 +288,10 @@ GEM
standard-performance (1.3.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.20.1)
stringio (3.0.9)
standard-rails (1.0.2)
lint_roller (~> 1.0)
rubocop-rails (~> 2.23.1)
stringio (3.1.0)
tapout (0.4.5)
ansi
json
Expand Down Expand Up @@ -315,6 +323,8 @@ DEPENDENCIES
rspec-ontap
rspec-rails
standard
standard-performance
standard-rails
websocket-driver!

RUBY VERSION
Expand Down
2 changes: 1 addition & 1 deletion app/interactors/parse_circle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def self.call(payload)
return unless payload["pull_requests"].blank?

status = Status.find_or_initialize_by(service: "circle", username: payload["username"], project_name: payload["reponame"])
status.payload = payload if ENV["DEBUG"]
status.payload = payload if Rails.configuration.x.debug
set_colors(status, payload["status"])
status.save!
end
Expand Down
2 changes: 1 addition & 1 deletion app/interactors/parse_github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def self.call(payload)
username, project_name = payload["repository"].split("/")
workflow = payload["workflow"]
status = Status.find_or_initialize_by(service: "github", username: username, project_name: project_name, workflow: workflow)
status.payload = payload if ENV["DEBUG"]
status.payload = payload if Rails.configuration.x.debug
set_colors(status, payload["status"])
status.save!
end
Expand Down
2 changes: 1 addition & 1 deletion app/interactors/parse_travis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def self.call(payload)
return if json["type"] == "pull_request"

status = Status.find_or_initialize_by(service: "travis", project_id: json["repository"]["id"].to_s)
status.payload = payload if ENV["DEBUG"]
status.payload = payload if Rails.configuration.x.debug
status.username = json["repository"]["owner_name"]
status.project_name = json["repository"]["name"]
set_colors(status, json["status_message"])
Expand Down
2 changes: 1 addition & 1 deletion app/interactors/trigger_webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def self.call(device)
{
"Content-Type": "application/json",
"x-ryg": device.ryg,
"x-device-url": Rails.application.routes.url_helpers.api_device_url(device, host: ENV["HOST"])
"x-device-url": Rails.application.routes.url_helpers.api_device_url(device, host: Rails.configuration.x.host)
})
end
end
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<%= csrf_meta_tags %>
<%= action_cable_meta_tag %>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_importmap_tags shim: !Rails.env.test? %>
<%= javascript_importmap_tags %>
</head>

<body<%= color_attrs_for_body(@colors) %>>
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ class Application < Rails::Application
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

config.x.debug = ENV["DEBUG"].present?
config.x.host = ENV["HOST"]
end
end
3 changes: 3 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# Show full error reports.
config.consider_all_requests_local = true

# Enable server timing
config.server_timing = true

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
Expand Down
20 changes: 0 additions & 20 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,4 @@

config.action_cable.url = "wss://#{ENV["HOST"]}/cable"
config.action_cable.allowed_request_origins = ["https://#{ENV["HOST"]}", "http://#{ENV["HOST"]}"]
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end
10 changes: 5 additions & 5 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Turn false under Spring and add config.action_view.cache_template_loading = true
# Turn false under Spring and add config.action_view.cache_template_loading = true.
config.cache_classes = true

# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
config.eager_load = ENV["CI"].present?

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
Expand Down
2 changes: 1 addition & 1 deletion config/importmap.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pin npm packages by running ./bin/importmap

pin "application", preload: true
pin "application"
pin "@rails/actioncable", to: "actioncable.esm.js"
pin_all_from "app/javascript/channels", under: "channels"
44 changes: 21 additions & 23 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header

# Rails.application.config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# Rails.application.configure do
# config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
#
# # Generate session nonces for permitted importmap and inline scripts
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src)
#
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true
# end

# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }

# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)

# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# Rails.application.config.content_security_policy_report_only = true
8 changes: 6 additions & 2 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Be sure to restart your server when you modify this file.

# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
# notations and behaviors.
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]
6 changes: 3 additions & 3 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.plural /^(ox)$/i, "\\1en"
# inflect.singular /^(ox)en/i, "\\1"
# inflect.irregular "person", "people"
# inflect.uncountable %w( fish sheep )
# end

Expand Down
18 changes: 10 additions & 8 deletions db/migrate/20121123195427_split_colors_on_statuses.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
class SplitColorsOnStatuses < ActiveRecord::Migration[4.2]
def change
remove_index :statuses, :color
remove_index :statuses, [:project_id, :color]
remove_index :statuses, [:project_id, :color, :created_at]
change_table :statuses, bulk: true do |t|
t.remove_index :color
t.remove_index [:project_id, :color]
t.remove_index [:project_id, :color, :created_at]

add_column :statuses, :red, :boolean
add_column :statuses, :yellow, :boolean
remove_column :statuses, :color
t.boolean :red
t.boolean :yellow
t.remove :color, type: :string

add_index :statuses, :red
add_index :statuses, :yellow
t.index :red
t.index :yellow
end
end
end
2 changes: 1 addition & 1 deletion db/migrate/20161012193415_add_service_to_status.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddServiceToStatus < ActiveRecord::Migration[5.0]
class Status < ActiveRecord::Base
class Status < ApplicationRecord
end

def up
Expand Down
6 changes: 4 additions & 2 deletions db/migrate/20230305131208_add_status_to_devices.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class AddStatusToDevices < ActiveRecord::Migration[7.0]
def change
add_column :devices, :status, :string
add_column :devices, :status_changed_at, :datetime
change_table :devices, bulk: true do |t|
t.string :status
t.datetime :status_changed_at
end
end
end
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.fixture_path = Rails.root.join("spec/fixtures")

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
Expand Down
2 changes: 1 addition & 1 deletion spec/support/json_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module JSONHelpers
ENV = {"CONTENT_TYPE" => "application/json"}.freeze

def json_fixture(filename)
File.read(Rails.root.join("spec", "fixtures", filename))
Rails.root.join("spec", "fixtures", filename).read
end
end

Expand Down

0 comments on commit 3287ff4

Please sign in to comment.