ramen-rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ramen-rails/ramen_after_filter.rb +7 -3
- data/lib/ramen-rails/version.rb +1 -1
- data/spec/lib/ramen_after_filter_spec.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1016f04b953432c937478ec7b0ba5108529dc24f
|
4
|
+
data.tar.gz: 8ebebd5f937a2ead5db67595224cddddad8cf4f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f439b4ba02ba3c50c7bf51d925cbb3511244e48916683afbb4eac732412b3be24f169af844d3531d7c94340077491a526572e85c10c5db8298692f6897ced56c
|
7
|
+
data.tar.gz: 3bc312d9c79ba50fb47a0a3af95c414b904381f4901d48f991b701ba5d860c8f87c9865018f812463d28f536aa0ed3ccf202171283b0177b15939f35bffa25ea
|
@@ -8,6 +8,8 @@ module RamenRails
|
|
8
8
|
|
9
9
|
class RamenAfterFilter
|
10
10
|
|
11
|
+
class InvalidUserObject < StandardError; end
|
12
|
+
|
11
13
|
include ScriptTagHelper
|
12
14
|
CLOSING_BODY_TAG = %r{</body>}
|
13
15
|
|
@@ -142,10 +144,12 @@ module RamenRails
|
|
142
144
|
|
143
145
|
user = ramen_user_object
|
144
146
|
|
145
|
-
|
147
|
+
raise InvalidUserObject.new("User #{user} does not respond to and have a present? #id") unless user.respond_to?(:id) && user.id.present?
|
148
|
+
raise InvalidUserObject.new("User #{user} does not respond to and have a present? #name") unless user.respond_to?(:name) && user.name.present?
|
149
|
+
raise InvalidUserObject.new("User #{user} does not respond to and have a present? #email") unless user.respond_to?(:email) && user.email.present?
|
146
150
|
|
147
|
-
[:email, :name].each do |attr|
|
148
|
-
obj[:user][attr] = user.send(attr)
|
151
|
+
[:email, :name, :id].each do |attr|
|
152
|
+
obj[:user][attr] = user.send(attr)
|
149
153
|
end
|
150
154
|
|
151
155
|
if user.respond_to?(:created_at) && user.send(:created_at).present?
|
data/lib/ramen-rails/version.rb
CHANGED
@@ -40,6 +40,18 @@ describe 'After filter' do
|
|
40
40
|
@dummy.current_user = {email: 'ryan@ramen.is', name: 'Ryan Angilly', id: 'person-1234'}
|
41
41
|
end
|
42
42
|
|
43
|
+
context "that does not respond to name" do
|
44
|
+
before :each do
|
45
|
+
@dummy.current_user = {email: 'ryan@ramen.is', id: 'person-1234'}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should throw an error" do
|
49
|
+
expect do
|
50
|
+
RamenRails::RamenAfterFilter.filter(@dummy)
|
51
|
+
end.to raise_error(RamenRails::RamenAfterFilter::InvalidUserObject)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
43
55
|
context "with a value proc set" do
|
44
56
|
before :each do |c|
|
45
57
|
@dummy.current_user.value = 1000
|