Skip to content

Commit

Permalink
Fix tests for AR < 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leonidkroka committed May 18, 2022
1 parent fbd940d commit ed0c456
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/support/postgresql/import_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def should_support_postgresql_import_functionality
books.first.id.to_s
end
end
let(:true_returning_value) { ENV['AR_VERSION'].to_f >= 5.0 ? true : 't' }
let(:false_returning_value) { ENV['AR_VERSION'].to_f >= 5.0 ? false : 'f' }

it "creates records" do
assert_difference("Book.count", +1) { result }
Expand Down Expand Up @@ -161,7 +163,7 @@ def should_support_postgresql_import_functionality
end

it "returns specified columns" do
assert_equal [['It', true]], result.results
assert_equal [['It', true_returning_value]], result.results
end
end

Expand All @@ -175,7 +177,7 @@ def should_support_postgresql_import_functionality
end

it "returns specified columns" do
assert_equal [['It', book_id, true]], result.results
assert_equal [['It', book_id, true_returning_value]], result.results
end
end

Expand Down Expand Up @@ -213,7 +215,7 @@ def should_support_postgresql_import_functionality
let(:returning_columns) { [:discount, "(xmax = '0') AS inserted"] }

it "sets custom model attributes" do
assert_not updated_promotion.inserted
assert_equal updated_promotion.inserted, false_returning_value
end
end
end
Expand Down

0 comments on commit ed0c456

Please sign in to comment.