cirandas.net

ref: master

test/unit/scope_tool.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require_relative "../test_helper"

class ScopeToolTest < ActiveSupport::TestCase
  include ScopeTool

  should 'unite scopes' do
    cmm = fast_create Community
    ent = fast_create Enterprise
    orgs = union(Profile.communities, Profile.enterprises)
    assert orgs.include? cmm
    assert orgs.include? ent
  end

  should 'filter united scopes' do
    cmm1 = fast_create Community, :visible => true
    cmm2 = fast_create Community, :visible => false
    ent1 = fast_create Enterprise, :visible => true
    ent2 = fast_create Enterprise, :visible => false
    orgs = union(Profile.communities, Profile.enterprises)
    assert orgs.include? cmm1
    assert orgs.include? cmm2
    assert orgs.include? ent1
    assert orgs.include? ent2
    orgs = orgs.visible
    assert orgs.include? cmm1
    refute orgs.include?(cmm2)
    assert orgs.include? ent1
    refute orgs.include?(ent2)
  end

end