Sha256: 6fa45dea54c74ed36227274cd3c46463bf1fbe2d17fd3c410be8a24e59867082

Contents?: true

Size: 948 Bytes

Versions: 11

Compression:

Stored size: 948 Bytes

Contents

#!/usr/bin/env ruby

$: << File.dirname(__FILE__)
$: << File.dirname(File.dirname(__FILE__))

require 'helper'
require "rails/all"

Oj::Rails.set_encoder()
Oj::Rails.optimize()

Oj.default_options = { mode: :rails }

class ActiveRecordResultTest < Minitest::Test
  def test_hash_rows
    result = ActiveRecord::Result.new(["one", "two"],
                                      [
                                        ["row 1 col 1", "row 1 col 2"],
                                        ["row 2 col 1", "row 2 col 2"],
                                        ["row 3 col 1", "row 3 col 2"],
                                      ])
    #puts "*** result: #{Oj.dump(result, indent: 2)}"
    json_result = if ActiveRecord.version >= Gem::Version.new("6")
                    result.to_a
                  else
                    result.to_hash
                  end

    assert_equal Oj.dump(result, mode: :rails), Oj.dump(json_result)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
oj-3.16.7 test/activerecord/result_test.rb
oj-3.16.6 test/activerecord/result_test.rb
oj-3.16.5 test/activerecord/result_test.rb
oj-3.16.4 test/activerecord/result_test.rb
oj-3.16.3 test/activerecord/result_test.rb
oj-3.16.2 test/activerecord/result_test.rb
oj-3.16.1 test/activerecord/result_test.rb
oj-3.16.0 test/activerecord/result_test.rb
oj-3.15.1 test/activerecord/result_test.rb
oj-3.15.0 test/activerecord/result_test.rb
oj-3.14.3 test/activerecord/result_test.rb