Sha256: f90deaafd3028f4268f4bc413658252b1c931ac3c10eb1e9a172ff28af314c40

Contents?: true

Size: 486 Bytes

Versions: 12

Compression:

Stored size: 486 Bytes

Contents

require 'test_helper'

class Superstore::Associations::HasManyTest < Superstore::TestCase
  class TestObject < Issue
  end

  test 'has_many' do
    issue = TestObject.create!
    label = Label.create! name: 'important', issue_id: issue.id

    assert_equal [label], issue.labels
  end

  test 'create supports preloaded records' do
    issue = TestObject.create!
    issue.labels = Label.all.to_a

    issue.labels.create! name: 'blue'

    assert_equal 1, issue.labels.size
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
superstore-2.4.4 test/unit/associations/has_many_test.rb
superstore-2.4.3 test/unit/associations/has_many_test.rb
superstore-2.4.2 test/unit/associations/has_many_test.rb
superstore-2.4.1 test/unit/associations/has_many_test.rb
superstore-2.4.0 test/unit/associations/has_many_test.rb
superstore-2.3.0 test/unit/associations/has_many_test.rb
superstore-2.2.0 test/unit/associations/has_many_test.rb
superstore-2.1.3 test/unit/associations/has_many_test.rb
superstore-2.1.2 test/unit/associations/has_many_test.rb
superstore-2.1.1 test/unit/associations/has_many_test.rb
superstore-2.1.0 test/unit/associations/has_many_test.rb
superstore-2.0.1 test/unit/associations/has_many_test.rb