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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 823b5e9bab357ec221cde51785d6c6e8707e7ae2
4
- data.tar.gz: 033b80fb3da59c5778ab1f8f566bfa0cf8c37976
3
+ metadata.gz: a604352a0e116f5da0d160f68ebf8a8c14a3bb34
4
+ data.tar.gz: e0efa67b57e875713e64a377c9a847088df863ba
5
5
  SHA512:
6
- metadata.gz: 1f737e5cfa5dfbd9b7922299a4ec383af710571179d4de71503d92342558f9ac331fe83bb94b129ac1e8f036f37a09ddadd6df41ad13f3b1d215a3a30fe8bd9b
7
- data.tar.gz: 961af27e3a10047502402cb1c6c556ab7c0be21365c28aabf6e23b065415f3978640639991efe985800e83502feb46bbde254bfce520896b4d5401fbea70170f
6
+ metadata.gz: 0283189127c7757ea6ad59a9b30f58be0a16fef867a77bab9717b82d5da83a06522aa822c182d21b7b0add692f866c1d5cdadba3a943379b26d26a7a936b7769
7
+ data.tar.gz: cf7100c507a619796d5d822ed87d5a6739026393df275c5cbb5e8d23fe9496475dc40c516891af9e301e50c8627f4e4707e3011d2e9d77fd33b252deeb7a4c1c
data/.travis.yml CHANGED
@@ -7,8 +7,5 @@ gemfile:
7
7
  - gemfiles/3.1.gemfile
8
8
  - gemfiles/3.2.gemfile
9
9
  - gemfiles/4.0.gemfile
10
- install: 'bundle install -j 4'
10
+ install: 'travis_retry bundle install -j 4'
11
11
  script: 'bundle exec rake'
12
- matrix:
13
- allow_failures:
14
- - rvm: jruby-19mode
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- guise (0.3.1)
4
+ guise (0.4.0)
5
5
  activerecord (>= 3.1, < 4.1)
6
6
  activesupport (>= 3.1, < 4.1)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- guise (0.3.1)
4
+ guise (0.4.0)
5
5
  activerecord (>= 3.1, < 4.1)
6
6
  activesupport (>= 3.1, < 4.1)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- guise (0.3.1)
4
+ guise (0.4.0)
5
5
  activerecord (>= 3.1, < 4.1)
6
6
  activesupport (>= 3.1, < 4.1)
7
7
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Guise
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
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 "#has_any_roles?" do
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.3.1
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-07 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord