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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 874f054b9efa68e517b81edb68ded87494f8d874
4
- data.tar.gz: ae256607eda7f2b22d73a0b367cfca64ea854535
3
+ metadata.gz: 1016f04b953432c937478ec7b0ba5108529dc24f
4
+ data.tar.gz: 8ebebd5f937a2ead5db67595224cddddad8cf4f7
5
5
  SHA512:
6
- metadata.gz: f8571e4aaadf89eea387c62116f471b010576c315c0ed5bafdb66fdee70dffc46e0548f5f513bb36b840fed10e6e98666957ffabe2178981e3fdfdb852d109e5
7
- data.tar.gz: 108def55a8332235d41d7f3e54fad34d7a1cc02ac250939ab9c94ccc67b8a09099d291ced068c68640b1fa48b1ab16c774b9cae62136c44293b17f61e45bb417
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
- obj[:user][:id] = user.id if user.respond_to?(:id) && user.id.present?
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) if user.respond_to?(attr) && user.send(attr).present?
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?
@@ -1,3 +1,3 @@
1
1
  module RamenRails
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramen-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Angilly