guise 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/gemfiles/3.1.gemfile.lock +1 -1
- data/gemfiles/3.2.gemfile.lock +1 -1
- data/gemfiles/4.0.gemfile.lock +1 -1
- data/lib/guise/introspection.rb +1 -1
- data/lib/guise/version.rb +1 -1
- data/spec/guise_spec.rb +35 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a604352a0e116f5da0d160f68ebf8a8c14a3bb34
|
4
|
+
data.tar.gz: e0efa67b57e875713e64a377c9a847088df863ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0283189127c7757ea6ad59a9b30f58be0a16fef867a77bab9717b82d5da83a06522aa822c182d21b7b0add692f866c1d5cdadba3a943379b26d26a7a936b7769
|
7
|
+
data.tar.gz: cf7100c507a619796d5d822ed87d5a6739026393df275c5cbb5e8d23fe9496475dc40c516891af9e301e50c8627f4e4707e3011d2e9d77fd33b252deeb7a4c1c
|
data/.travis.yml
CHANGED
data/gemfiles/3.1.gemfile.lock
CHANGED
data/gemfiles/3.2.gemfile.lock
CHANGED
data/gemfiles/4.0.gemfile.lock
CHANGED
data/lib/guise/introspection.rb
CHANGED
@@ -11,7 +11,7 @@ module Guise
|
|
11
11
|
raise ArgumentError, "no such guise #{value}"
|
12
12
|
end
|
13
13
|
|
14
|
-
guises.any? { |guise| guise[guise_options[:attribute]] == value }
|
14
|
+
guises.any? { |guise| !guise.marked_for_destruction? && guise[guise_options[:attribute]] == value }
|
15
15
|
end
|
16
16
|
|
17
17
|
def has_any_guises?(*values)
|
data/lib/guise/version.rb
CHANGED
data/spec/guise_spec.rb
CHANGED
@@ -47,6 +47,16 @@ describe Guise do
|
|
47
47
|
expect { user.has_guise?(:Accountant) }.to raise_error ArgumentError
|
48
48
|
end
|
49
49
|
|
50
|
+
it 'ignores records marked for destruction' do
|
51
|
+
technician_role = build(:user_role, name: 'Technician')
|
52
|
+
technician_user = create(:user, user_roles: [technician_role])
|
53
|
+
|
54
|
+
expect(technician_user).to have_guise :technician
|
55
|
+
|
56
|
+
technician_role.mark_for_destruction
|
57
|
+
expect(technician_user).not_to have_guise :technician
|
58
|
+
end
|
59
|
+
|
50
60
|
it 'is aliased based on the name of the association' do
|
51
61
|
expect(user).not_to have_user_role :technician
|
52
62
|
expect(technician).to have_user_role :technician
|
@@ -72,18 +82,42 @@ describe Guise do
|
|
72
82
|
expect(supervisor).to have_guises :Supervisor, :Technician
|
73
83
|
end
|
74
84
|
|
85
|
+
it 'ignores records marked for destruction' do
|
86
|
+
technician_role = build(:user_role, name: 'Technician')
|
87
|
+
supervisor_role = build(:user_role, name: 'Supervisor')
|
88
|
+
user = create(:user, user_roles: [technician_role, supervisor_role])
|
89
|
+
|
90
|
+
expect(user).to have_guises :technician, :supervisor
|
91
|
+
|
92
|
+
technician_role.mark_for_destruction
|
93
|
+
|
94
|
+
expect(user).not_to have_guises :technician, :supervisor
|
95
|
+
expect(user).not_to have_guises :technician
|
96
|
+
expect(user).to have_guises :supervisor
|
97
|
+
end
|
98
|
+
|
75
99
|
it 'is aliased based on the association name' do
|
76
100
|
expect(technician).not_to have_user_roles :Supervisor, :Technician
|
77
101
|
expect(supervisor).to have_user_roles :Supervisor, :Technician
|
78
102
|
end
|
79
103
|
end
|
80
104
|
|
81
|
-
describe "#
|
105
|
+
describe "#has_any_guises?" do
|
82
106
|
it "checks if resource is any of the supplied roles" do
|
83
107
|
expect(user).not_to have_any_guises :Supervisor, :Technician
|
84
108
|
expect(technician).to have_any_guises 'supervisor', 'technician'
|
85
109
|
end
|
86
110
|
|
111
|
+
it 'ignores records marked for destruction' do
|
112
|
+
technician_role = build(:user_role, name: 'Technician')
|
113
|
+
technician_user = create(:user, user_roles: [technician_role])
|
114
|
+
|
115
|
+
expect(technician_user).to have_any_guises :technician, :supervisor
|
116
|
+
|
117
|
+
technician_role.mark_for_destruction
|
118
|
+
expect(technician_user).not_to have_any_guises :technician, :supervisor
|
119
|
+
end
|
120
|
+
|
87
121
|
it 'is aliased based on the association name' do
|
88
122
|
expect(user).not_to have_any_user_roles :Supervisor, :Technician
|
89
123
|
expect(technician).to have_any_user_roles 'supervisor', 'Technician'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Gutierrez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|