|
5 | 5 | require "statesman/adapters/shared_examples" |
6 | 6 | require "statesman/exceptions" |
7 | 7 |
|
8 | | -describe Statesman::Adapters::ActiveRecord, active_record: true do |
| 8 | +describe Statesman::Adapters::ActiveRecord, :active_record do |
9 | 9 | before do |
10 | 10 | prepare_model_table |
11 | 11 | prepare_transitions_table |
12 | 12 |
|
13 | | - MyActiveRecordModelTransition.serialize(:metadata, JSON) |
| 13 | + # MyActiveRecordModelTransition.serialize(:metadata, JSON) |
14 | 14 |
|
15 | 15 | prepare_sti_model_table |
16 | 16 | prepare_sti_transitions_table |
|
38 | 38 | allow(metadata_column).to receive_messages(sql_type: "") |
39 | 39 | allow(MyActiveRecordModelTransition).to receive_messages(columns_hash: |
40 | 40 | { "metadata" => metadata_column }) |
41 | | - if ActiveRecord.respond_to?(:gem_version) && |
42 | | - ActiveRecord.gem_version >= Gem::Version.new("4.2.0.a") |
43 | | - expect(MyActiveRecordModelTransition). |
44 | | - to receive(:type_for_attribute).with("metadata"). |
45 | | - and_return(ActiveRecord::Type::Value.new) |
46 | | - else |
47 | | - expect(MyActiveRecordModelTransition). |
48 | | - to receive_messages(serialized_attributes: {}) |
49 | | - end |
| 41 | + expect(MyActiveRecordModelTransition). |
| 42 | + to receive(:type_for_attribute).with("metadata"). |
| 43 | + and_return(ActiveRecord::Type::Value.new) |
50 | 44 | end |
51 | 45 |
|
52 | 46 | it "raises an exception" do |
|
91 | 85 | allow(metadata_column).to receive_messages(sql_type: "jsonb") |
92 | 86 | allow(MyActiveRecordModelTransition).to receive_messages(columns_hash: |
93 | 87 | { "metadata" => metadata_column }) |
94 | | - if ActiveRecord.respond_to?(:gem_version) && |
95 | | - ActiveRecord.gem_version >= Gem::Version.new("4.2.0.a") |
96 | | - serialized_type = ActiveRecord::Type::Serialized.new( |
97 | | - "", ActiveRecord::Coders::JSON |
98 | | - ) |
99 | | - expect(MyActiveRecordModelTransition). |
100 | | - to receive(:type_for_attribute).with("metadata"). |
101 | | - and_return(serialized_type) |
102 | | - else |
103 | | - expect(MyActiveRecordModelTransition). |
104 | | - to receive_messages(serialized_attributes: { "metadata" => "" }) |
105 | | - end |
| 88 | + serialized_type = ActiveRecord::Type::Serialized.new( |
| 89 | + "", ActiveRecord::Coders::JSON |
| 90 | + ) |
| 91 | + expect(MyActiveRecordModelTransition). |
| 92 | + to receive(:type_for_attribute).with("metadata"). |
| 93 | + and_return(serialized_type) |
106 | 94 | end |
107 | 95 |
|
108 | 96 | it "raises an exception" do |
|
467 | 455 | CreateNamespacedARModelTransitionMigration.migrate(:up) |
468 | 456 | end |
469 | 457 |
|
470 | | - before do |
471 | | - MyNamespace::MyActiveRecordModelTransition.serialize(:metadata, JSON) |
472 | | - end |
473 | | - |
474 | 458 | let(:observer) { double(Statesman::Machine, execute: nil) } |
475 | 459 | let(:model) do |
476 | 460 | MyNamespace::MyActiveRecordModel.create(current_state: :pending) |
|
0 commit comments