Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .app-image-tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.10.1.2
v0.10.1.3
13 changes: 10 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup database
run: bundle exec rake db:setup

- name: Run RSpec tests
run: |
bundle exec rake db:setup
bundle exec rspec --format progress
run: bundle exec rspec --format progress --tag ~integration

- name: Run RSpec integration tests
env:
PG_REPLICA_HOST: postgres_primary
PG_REPLICA_PORT: 5432
run: bundle exec rspec --format progress --tag integration

- name: Upload Coverage Report
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--format documentation
--color
--order random
--require spec_helper
--require spec_helper
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Add Ruby 4.0.0 to test matrix
- Hijack only higher-level active record adapter methods [1d7eae3](https://github.com/Nasdaq/active_record_proxy_adapters/commit/1d7eae3a9c7a75cc4adebe64a1fdc1289205bfe)
- Add ActiveRecord model integration tests [2ab16e1](https://github.com/Nasdaq/active_record_proxy_adapters/commit/2ab16e196410b9985d29a976fb64d58171f483e3)

## [0.10.1, 0.9.2] - 2026-01-02
- Fix hijacked methods for all supported ActiveRecord versions [bc0501a](https://github.com/Nasdaq/active_record_proxy_adapters/commit/bc0501af613193db4d0e67c44234b8ea6e7038e4)
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ group :test do
gem "rubocop", "~> 1.82"
gem "rubocop-rspec", "~> 3.8.0"
gem "simplecov"
gem "timecop"
end

# Specify your gem's dependencies in active_record_proxy_adapters.gemspec
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ GEM
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
thor (1.4.0)
timecop (0.9.10)
timeout (0.4.4)
trilogy (2.9.0)
tzinfo (2.0.6)
Expand Down Expand Up @@ -154,6 +155,7 @@ DEPENDENCIES
rubocop (~> 1.82)
rubocop-rspec (~> 3.8.0)
simplecov
timecop
trilogy (~> 2.9)
yard

Expand Down
6 changes: 5 additions & 1 deletion bin/rspec-all-versions
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ run_tests() {
local env_number=${ar//./_}

TEST_ENV_NUMBER=$env_number $bin_dir/appraisal-exec $ar rake db:drop db:setup
TEST_ENV_NUMBER=$env_number $bin_dir/appraisal-exec $ar rspec -fp --fail-fast
TEST_ENV_NUMBER=$env_number $bin_dir/appraisal-exec $ar rspec -fp --fail-fast --tag ~integration
TEST_ENV_NUMBER=$env_number \
PG_REPLICA_HOST=$PG_PRIMARY_HOST \
PG_REPLICA_PORT=$PG_PRIMARY_PORT \
$bin_dir/appraisal-exec $ar rspec -fp --fail-fast --tag integration
}

active_record_versions() {
Expand Down
5 changes: 3 additions & 2 deletions db/mysql_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
DROP TABLE IF EXISTS `schema_migrations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `schema_migrations` (
`version` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` text NOT NULL,
`email` text NOT NULL,
`age` int(11) NOT NULL DEFAULT 0,
`created_at` timestamp NULL DEFAULT current_timestamp(),
`updated_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
Expand Down
1 change: 1 addition & 0 deletions db/postgresql_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CREATE TABLE public.users (
id integer NOT NULL,
name text NOT NULL,
email text NOT NULL,
age integer DEFAULT 0 NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
updated_at timestamp without time zone DEFAULT now() NOT NULL
);
Expand Down
1 change: 1 addition & 0 deletions db/sqlite3_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CREATE TABLE users (
id integer PRIMARY KEY NOT NULL,
name text NOT NULL,
email text NOT NULL,
age integer not null default 0,
created_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
);
Expand Down
1 change: 1 addition & 0 deletions gemfiles/ar_7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ group :test do
gem "rubocop", "~> 1.82"
gem "rubocop-rspec", "~> 3.8.0"
gem "simplecov"
gem "timecop"
end

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/ar_8.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ group :test do
gem "rubocop", "~> 1.82"
gem "rubocop-rspec", "~> 3.8.0"
gem "simplecov"
gem "timecop"
end

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/ar_8.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ group :test do
gem "rubocop", "~> 1.82"
gem "rubocop-rspec", "~> 3.8.0"
gem "simplecov"
gem "timecop"
end

gemspec path: "../"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require "shared_examples/a_proxied_model"

RSpec.describe "A Mysql2ProxyAdapter-backed model", :integration do # rubocop:disable RSpec/DescribeClass
it_behaves_like "a proxied model" do
let(:model_class) { TestHelper::Mysql2Record }
let(:database_identifier) { :mysql2 }
let(:log_subscriber_primary_prefix) { "mysql2_primary" }
let(:log_subscriber_replica_prefix) { "mysql2_replica" }
let(:truncate_database) { TestHelper.truncate_mysql2_database }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require "shared_examples/a_proxied_model"

RSpec.describe "A PostgreSQLProxyAdapter-backed model", :integration do # rubocop:disable RSpec/DescribeClass
it_behaves_like "a proxied model" do
let(:model_class) { TestHelper::PostgreSQLRecord }
let(:database_identifier) { :postgresql }
let(:log_subscriber_primary_prefix) { "postgresql_primary" }
let(:log_subscriber_replica_prefix) { "postgresql_replica" }
let(:truncate_database) { TestHelper.truncate_postgresql_database }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require "shared_examples/a_proxied_model"

RSpec.describe "A SQLite3ProxyAdapter-backed model", :integration do # rubocop:disable RSpec/DescribeClass
it_behaves_like "a proxied model" do
let(:model_class) { TestHelper::SQLite3Record }
let(:database_identifier) { :sqlite3 }
let(:log_subscriber_primary_prefix) { "sqlite3_primary" }
let(:log_subscriber_replica_prefix) { "sqlite3_replica" }
let(:truncate_database) { TestHelper.truncate_sqlite3_database }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require "shared_examples/a_proxied_model"

RSpec.describe "A TrilogyProxyAdapter-backed model", :integration do # rubocop:disable RSpec/DescribeClass
it_behaves_like "a proxied model" do
let(:model_class) { TestHelper::TrilogyRecord }
let(:database_identifier) { :trilogy }
let(:log_subscriber_primary_prefix) { "trilogy_primary" }
let(:log_subscriber_replica_prefix) { "trilogy_replica" }
let(:truncate_database) { TestHelper.truncate_trilogy_database }
end
end
6 changes: 1 addition & 5 deletions spec/active_record_proxy_adapters/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def from_cookie_string(cookie_string)
end
end

describe "#call" do
describe "#call", freeze_time: { to: Time.utc(2026) } do
let(:middleware) { described_class.new(app, {}) }

let(:app) do
Expand All @@ -44,12 +44,8 @@ def from_cookie_string(cookie_string)
config.proxy_delay = 2.seconds
config.checkout_timeout = 2.seconds
end

travel_to(Time.utc(2025))
end

after { travel_back }

context "when context cookie is not set" do
it "initializes the cookie with an empty hash" do
env = {}
Expand Down
Loading