diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 37739af..c24f9b4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -9,6 +9,12 @@ jobs:
include:
- ruby: 3.3
gemfile: Gemfile
+ # - ruby: 3.3
+ # gemfile: gemfiles/rails72.gemfile
+ # - ruby: 3.2
+ # gemfile: gemfiles/rails71.gemfile
+ # - ruby: 3.1
+ # gemfile: gemfiles/rails70.gemfile
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
steps:
@@ -18,5 +24,14 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake compile
+ - run: bundle exec rake test
+
+ - uses: ankane/setup-postgres@v1
+ - run: ADAPTER=postgresql bundle exec rake test
+
+ - uses: ankane/setup-mysql@v1
+ - run: ADAPTER=mysql2 bundle exec rake test
+ - run: ADAPTER=trilogy bundle exec rake test
+
- run: sudo apt-get update && sudo apt-get install valgrind
- run: bundle exec rake test:valgrind
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8749bcd..7206416 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+## 0.7.0 (2024-10-22)
+
+- Added support for Trilogy
+- Dropped support for Ruby < 3.1 and Rails < 7
+
+## 0.6.1 (2024-09-04)
+
+- Improved CSP support
+
## 0.6.0 (2023-07-02)
- Fixed support for aliases, dates, and times in config file
diff --git a/Gemfile b/Gemfile
index 20944f7..e4f2932 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,9 +6,10 @@ gem "rake"
gem "rake-compiler"
gem "minitest"
gem "combustion"
-gem "rails", "~> 7.1.0"
+gem "rails", "~> 8.0.0"
gem "sqlite3"
gem "mysql2"
+gem "trilogy"
gem "pg"
gem "benchmark-ips"
gem "ruby_memcheck"
diff --git a/LICENSE.txt b/LICENSE.txt
index 3d934c2..261f263 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2016-2023 Andrew Kane
+Copyright (c) 2016-2024 Andrew Kane
MIT License
diff --git a/app/views/field_test/experiments/_experiments.html.erb b/app/views/field_test/experiments/_experiments.html.erb
index c6714f8..3aad972 100644
--- a/app/views/field_test/experiments/_experiments.html.erb
+++ b/app/views/field_test/experiments/_experiments.html.erb
@@ -20,10 +20,10 @@
Variant |
- Participants |
- Conversions |
- Conversion Rate |
- Prob Winning |
+ Participants |
+ Conversions |
+ Conversion Rate |
+ Prob Winning |
diff --git a/app/views/field_test/experiments/show.html.erb b/app/views/field_test/experiments/show.html.erb
index 42a0560..b389213 100644
--- a/app/views/field_test/experiments/show.html.erb
+++ b/app/views/field_test/experiments/show.html.erb
@@ -14,9 +14,9 @@
Participant |
- Variant |
- Converted |
- Started |
+ Variant |
+ Converted |
+ Started |
diff --git a/app/views/field_test/participants/show.html.erb b/app/views/field_test/participants/show.html.erb
index 0616728..f9fdd51 100644
--- a/app/views/field_test/participants/show.html.erb
+++ b/app/views/field_test/participants/show.html.erb
@@ -10,9 +10,9 @@
Experiment |
- Variant |
- Converted |
- Started |
+ Variant |
+ Converted |
+ Started |
@@ -23,7 +23,7 @@
<% experiment = FieldTest::Experiment.find(membership.experiment) rescue nil %>
<% if experiment %>
<%= form_for membership do |f| %>
- <%= f.select "variant", options_for_select(FieldTest::Experiment.find(membership.experiment).variants.map { |v| [v, v] }, membership.variant), {}, onchange: "this.form.submit()" %>
+ <%= f.select "variant", options_for_select(FieldTest::Experiment.find(membership.experiment).variants.map { |v| [v, v] }, membership.variant) %>
<% end %>
<% else %>
<%= membership.variant %>
@@ -60,3 +60,12 @@
<% end %>
+
+<%= javascript_tag nonce: true do %>
+ var selects = document.querySelectorAll(".edit_membership select");
+ for (var i = 0; i < selects.length; i++) {
+ selects[i].addEventListener("change", function () {
+ this.form.submit();
+ });
+ }
+<% end %>
diff --git a/app/views/layouts/field_test/application.html.erb b/app/views/layouts/field_test/application.html.erb
index 2864e18..ab66fb5 100644
--- a/app/views/layouts/field_test/application.html.erb
+++ b/app/views/layouts/field_test/application.html.erb
@@ -1,8 +1,11 @@
+
Field Test
-
+
+ .width-20 {
+ width: 20%;
+ }
+ <% end %>
<%= yield %>
diff --git a/field_test.gemspec b/field_test.gemspec
index 16a5ea6..5ab68b6 100644
--- a/field_test.gemspec
+++ b/field_test.gemspec
@@ -14,10 +14,10 @@ Gem::Specification.new do |spec|
spec.require_path = "lib"
spec.extensions = ["ext/field_test/extconf.rb"]
- spec.required_ruby_version = ">= 3"
+ spec.required_ruby_version = ">= 3.1"
- spec.add_dependency "railties", ">= 6.1"
- spec.add_dependency "activerecord", ">= 6.1"
+ spec.add_dependency "railties", ">= 7"
+ spec.add_dependency "activerecord", ">= 7"
spec.add_dependency "browser", ">= 2"
- spec.add_dependency "rice", ">= 4.0.2"
+ spec.add_dependency "rice", ">= 4.3.3"
end
diff --git a/gemfiles/rails70.gemfile b/gemfiles/rails70.gemfile
index 9a4048e..ce0d337 100644
--- a/gemfiles/rails70.gemfile
+++ b/gemfiles/rails70.gemfile
@@ -7,6 +7,7 @@ gem "rake-compiler"
gem "minitest"
gem "combustion"
gem "rails", "~> 7.0.0"
-gem "sqlite3"
+gem "sqlite3", "< 2"
gem "mysql2"
+gem "activerecord-trilogy-adapter"
gem "pg"
diff --git a/gemfiles/rails71.gemfile b/gemfiles/rails71.gemfile
new file mode 100644
index 0000000..7860c21
--- /dev/null
+++ b/gemfiles/rails71.gemfile
@@ -0,0 +1,13 @@
+source "https://rubygems.org"
+
+gemspec path: ".."
+
+gem "rake"
+gem "rake-compiler"
+gem "minitest"
+gem "combustion"
+gem "rails", "~> 7.1.0"
+gem "sqlite3", "< 2"
+gem "mysql2"
+gem "trilogy"
+gem "pg"
diff --git a/gemfiles/rails61.gemfile b/gemfiles/rails72.gemfile
similarity index 79%
rename from gemfiles/rails61.gemfile
rename to gemfiles/rails72.gemfile
index 33ef807..9ba337e 100644
--- a/gemfiles/rails61.gemfile
+++ b/gemfiles/rails72.gemfile
@@ -6,7 +6,8 @@ gem "rake"
gem "rake-compiler"
gem "minitest"
gem "combustion"
-gem "rails", "~> 6.1.0"
+gem "rails", "~> 7.2.0"
gem "sqlite3"
gem "mysql2"
+gem "trilogy"
gem "pg"
diff --git a/lib/field_test.rb b/lib/field_test.rb
index 7bb827a..a53b16f 100644
--- a/lib/field_test.rb
+++ b/lib/field_test.rb
@@ -58,13 +58,14 @@ def self.precision
def self.events_supported?
unless defined?(@events_supported)
- connection = FieldTest::Membership.connection
table_name = "field_test_events"
@events_supported =
- if connection.respond_to?(:data_source_exists?)
- connection.data_source_exists?(table_name)
- else
- connection.table_exists?(table_name)
+ FieldTest::Membership.connection_pool.with_connection do |connection|
+ if connection.respond_to?(:data_source_exists?)
+ connection.data_source_exists?(table_name)
+ else
+ connection.table_exists?(table_name)
+ end
end
end
@events_supported
diff --git a/lib/field_test/experiment.rb b/lib/field_test/experiment.rb
index 7f1240a..6b13ca9 100644
--- a/lib/field_test/experiment.rb
+++ b/lib/field_test/experiment.rb
@@ -112,13 +112,13 @@ def results(goal: nil)
participated = relation.count
- adapter_name = relation.connection.adapter_name
+ adapter_name = relation.connection_db_config.adapter.to_s
column =
if FieldTest.legacy_participants
:participant
- elsif adapter_name =~ /postg/i # postgres
+ elsif adapter_name.match?(/postg/i) # postgres
"(participant_type, participant_id)"
- elsif adapter_name =~ /mysql/i
+ elsif adapter_name.match?(/mysql|trilogy/i)
"COALESCE(participant_type, ''), participant_id"
else
# SQLite supports single column
diff --git a/lib/field_test/version.rb b/lib/field_test/version.rb
index 51413d5..69a2d58 100644
--- a/lib/field_test/version.rb
+++ b/lib/field_test/version.rb
@@ -1,3 +1,3 @@
module FieldTest
- VERSION = "0.6.0"
+ VERSION = "0.7.0"
end
diff --git a/test/dashboard_test.rb b/test/dashboard_test.rb
new file mode 100644
index 0000000..0f4ff54
--- /dev/null
+++ b/test/dashboard_test.rb
@@ -0,0 +1,8 @@
+require_relative "test_helper"
+
+class DashboardTest < ActionDispatch::IntegrationTest
+ def test_root
+ get field_test_engine.root_path
+ assert_response :success
+ end
+end
diff --git a/test/internal/config/database.yml b/test/internal/config/database.yml
index e2a3e76..40330a7 100644
--- a/test/internal/config/database.yml
+++ b/test/internal/config/database.yml
@@ -1,3 +1,4 @@
test:
adapter: <%= ENV["ADAPTER"] || "sqlite3" %>
- database: <%= ["postgresql", "mysql2"].include?(ENV["ADAPTER"]) ? "field_test_test" : "db/combustion_test.sqlite" %>
+ database: <%= ["postgresql", "mysql2", "trilogy"].include?(ENV["ADAPTER"]) ? "field_test_test" : "db/combustion_test.sqlite" %>
+ host: <%= ENV["ADAPTER"] == "trilogy" ? "127.0.0.1" : nil %>
diff --git a/test/internal/config/routes.rb b/test/internal/config/routes.rb
index c1ed0eb..e80a52d 100644
--- a/test/internal/config/routes.rb
+++ b/test/internal/config/routes.rb
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
resources :users, only: [:index]
get "exclude", to: "users#exclude"
+ mount FieldTest::Engine, at: "field_test"
end