cirandas.net

ref: master

test/unit/circle_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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require_relative "../test_helper"

class CircleTest < ActiveSupport::TestCase

  should 'two circles with same name and different profile types' do
    person = create_user('testinguser').person

    circle1 = create(Circle, :name => 'test', :profile_type => 'Enterprise', :person => person)
    circle2 = create(Circle, :name => 'test', :profile_type => 'Community', :person => person)

    circles = Circle.all
    assert_includes circles, circle2
  end

  should 'two circles with same name and same profile types' do
    person = create_user('testinguser').person
  
    circle1 = create(Circle, :name => 'test', :profile_type => 'Enterprise', :person => person)
    circle2 = Circle.new(:name => 'test', :profile_type => 'Enterprise', :person => person)
    refute circle2.valid?
  end
  
  should 'two circles with different names and same profile types' do
    person = create_user('testinguser').person
  
    circle1 = create(Circle, :name => 'test', :profile_type => 'Enterprise', :person => person)
    circle2 = create(Circle, :name => 'different-test', :profile_type => 'Enterprise', :person => person)
  
    circles = Circle.all
    assert_includes circles, circle2
  end
  
  should 'two circles with different names and different profile types' do
    person = create_user('testinguser').person
  
    circle1 = create(Circle, :name => 'test', :profile_type => 'Enterprise', :person => person)
    circle2 = create(Circle, :name => 'different-test', :profile_type => 'Community', :person => person)

    circles = Circle.all
    assert_includes circles, circle2
  end
  
end