Skip to content

Commit

Permalink
Merge pull request #65 from learn-co/gardening-insert-at-on-rails-6-plus
Browse files Browse the repository at this point in the history
support inserted_at on rails 6 plus
  • Loading branch information
altintx authored May 2, 2022
2 parents 4147f75 + b8f7558 commit 8aa0051
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
test:
parallelism: 1
docker:
- image: circleci/ruby:2.6.5-node-browsers
- image: cimg/ruby:2.7.2-browsers
environment: &environment
PGHOST: localhost
PGUSERNAME: postgres
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.5
2.7.2
10 changes: 10 additions & 0 deletions lib/railway_ipc/models/consumed_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,18 @@ def processed?

private

# rails <= 5.1 uses this method to know the name of the created_at/updated_at fields
def timestamp_attributes_for_create
super << :inserted_at
end

# rails >= 6.0 moved this to the class level and uses strings instead of symbols
class << self
private

def timestamp_attributes_for_create
super << 'inserted_at'
end
end
end
end
10 changes: 10 additions & 0 deletions lib/railway_ipc/models/published_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ def self.store_message(outgoing_message)

private

# rails <= 5.1 uses this method to know the name of the created_at/updated_at fields
def timestamp_attributes_for_create
super << :inserted_at
end

# rails >= 6.0 moved this to the class level and uses strings instead of symbols
class << self
private

def timestamp_attributes_for_create
super << 'inserted_at'
end
end
end
end
2 changes: 1 addition & 1 deletion lib/railway_ipc/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RailwayIpc
VERSION = '5.0.0'
VERSION = '5.1.0'
end
2 changes: 1 addition & 1 deletion priv/migrations/add_railway_ipc_consumed_messages.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class AddRailwayIpcConsumedMessages < ActiveRecord::Migration
class AddRailwayIpcConsumedMessages < ActiveRecord::Migration[4.2]
def change
create_table :railway_ipc_consumed_messages do |t|
t.uuid :uuid, null: false
Expand Down
2 changes: 1 addition & 1 deletion priv/migrations/add_railway_ipc_published_messages.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class AddRailwayIpcPublishedMessages < ActiveRecord::Migration
class AddRailwayIpcPublishedMessages < ActiveRecord::Migration[4.2]
def change
create_table :railway_ipc_published_messages, id: false do |t|
t.uuid :uuid, null: false
Expand Down
4 changes: 2 additions & 2 deletions railway_ipc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Gem::Specification.new do |spec|
# Setup for testing Rails type code within mock Rails app
spec.add_development_dependency 'database_cleaner', '~> 1.7'
spec.add_development_dependency 'listen', '~> 3.0.5'
spec.add_development_dependency 'pg', '~> 0.18'
spec.add_development_dependency 'pg', '~> 1.1'
spec.add_development_dependency 'pry', '~> 0.13'
spec.add_development_dependency 'rails', '~> 5.0.7'
spec.add_development_dependency 'rails', '~> 6.0'
spec.add_development_dependency 'rspec-rails'
spec.add_development_dependency 'shoulda-matchers', '~> 4.2'
end
4 changes: 2 additions & 2 deletions spec/support/rails_app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end

gem 'rails', '~> 5.0.7'
gem 'rails', '~> 6.0'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.0'

Expand All @@ -25,4 +25,4 @@ end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'railway-ipc', path: '../../..'
gem 'google-protobuf', '~> 3.9'
gem 'google-protobuf', '~> 3.20.0'
6 changes: 3 additions & 3 deletions spec/support/rails_app/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../../..
specs:
railway-ipc (2.2.1)
railway-ipc (5.0.0)
bunny (~> 2.2.0)
sneakers (~> 2.3.5)

Expand Down Expand Up @@ -57,7 +57,7 @@ GEM
ffi (1.13.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
google-protobuf (3.12.2)
google-protobuf (3.20.1)
i18n (1.8.4)
concurrent-ruby (~> 1.0)
listen (3.0.8)
Expand Down Expand Up @@ -140,7 +140,7 @@ PLATFORMS

DEPENDENCIES
byebug
google-protobuf (~> 3.9)
google-protobuf (~> 3.20.0)
listen (~> 3.0.5)
pg (>= 0.18, < 2.0)
puma (~> 3.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,5 @@
# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = true

# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = false

# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
Rails.application.config.ssl_options = { hsts: { subdomains: true } }

0 comments on commit 8aa0051

Please sign in to comment.