cirandas.net

ref: master

plugins/sub_organizations/test/unit/organization_test.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'test_helper'

class OrganizationTest < ActiveSupport::TestCase

  should 'inlude the parent field in organization' do
    organization = Organization.new
    assert_nothing_raised { organization.sub_organizations_plugin_parent_to_be = '999' }
  end

  should 'include the parent field in the FIELDS constant' do
    assert_includes Organization::FIELDS, 'sub_organizations_plugin_parent_to_be'
  end

  should 'relate organization with parent if the attribute is set' do
    parent = fast_create(Organization)
    organization = build(Organization, :identifier => 'some-org',:name => 'Some Org', :sub_organizations_plugin_parent_to_be => parent.id)
    assert_not_includes Organization.children(parent), organization

    organization.save!
    assert_includes Organization.children(parent), organization
  end

end