Skip to content

Commit 7b7ba43

Browse files
authored
Warn about ActiveRecord value column migration (#1013)
1 parent 5dbd18c commit 7b7ba43

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

lib/flipper/adapters/active_record.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ def with_write_connection(model = @feature_class, &block)
299299

300300
def warned_about_value_not_text?
301301
return @warned_about_value_not_text if defined?(@warned_about_value_not_text)
302+
302303
@warned_about_value_not_text = true
304+
false
303305
end
304306
end
305307
end

spec/flipper/adapters/active_record_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@
9292
end
9393
end
9494

95+
it "warns once if the gates value column is not text" do
96+
allow(Flipper::Adapters::ActiveRecord::Gate).
97+
to receive(:column_for_attribute).
98+
with(:value).
99+
and_return(double(type: :string))
100+
101+
output = capture_output do
102+
2.times { subject.features }
103+
end
104+
105+
expect(output.scan("Your database needs to be migrated").size).to eq(1)
106+
end
107+
95108
context "ActiveRecord connection_pool" do
96109
before do
97110
clear_active_connections!

0 commit comments

Comments
 (0)