Sha256: a5e663e42477ab33016fa7687122063808ac5d8f59467e567db41f75b0d2dfc5

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

require 'test_helper'

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

  test 'has_many active_record association' 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

    issue.labels.create! name: 'blue'

    assert_equal 1, issue.labels.size
  end

  test 'has_many superstore association' do
    parent_issue = Issue.create!
    child_issue = Issue.create! parent_issue: parent_issue

    assert_equal [child_issue], parent_issue.children_issues
    assert_equal parent_issue.object_id, parent_issue.children_issues.first.parent_issue.object_id
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
superstore-3.0.0 test/unit/associations/has_many_test.rb
superstore-2.5.0 test/unit/associations/has_many_test.rb