ramen-rails 0.0.8 → 0.0.9

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: 0304673a1479bb4520012e46b5b5c3bcc04b0921
4
- data.tar.gz: ac116b3c00a3f5f47ddafc7d03e2e4bef8712a4d
3
+ metadata.gz: 6ecbd257a3ef2196806c9e499e7a6c42cd792834
4
+ data.tar.gz: 21aac8f007330ac61ad54f9b7a7195e8b3cd14d0
5
5
  SHA512:
6
- metadata.gz: baf021f697ff2ed7a24b52feb9598a87f7180dac43ad3966186af524d5bbaa5ec02006f17689cbcff23a660547bf63e75315c8479637918c81536f9fddcb2a4c
7
- data.tar.gz: bc3321d94ebc3f498492a316cdd016a452433d526bcf94dd07920afe0aa6b0eca14270cca73ae3c029c962037320ff599688034aa25ee82cbc80c0743465ca4a
6
+ metadata.gz: 8b86b0eb020f62a10b421334387859b809b9ddf62b0e4468ec331bc3a46357356fc13ba8635063b3d613e60ecc8f969c8b3876072c29d8aa6e4a9421ef934684
7
+ data.tar.gz: a9e74c76bc5c53eb7b7bb28535d4940ca1148e355cb04b9978c0beef653936aa6c2e1bea18a40702355ad5bb4550ce430a22f3ede37b6ff8c0eab1fc1b803a21
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ramen-rails (0.0.7)
4
+ ramen-rails (0.0.9)
5
5
  activesupport (~> 4.0)
6
6
 
7
7
  GEM
@@ -12,13 +12,14 @@ RamenRails.config do |config|
12
12
 
13
13
  ## Important note regarding `-> {}` vs. `Proc.new {}`
14
14
  ##
15
- ## Use `Proc.new {}` and not `-> {}`. There's some weirdness
16
- ## in how instance_eval works that will bite you in the butt
17
- ## otherwise.
15
+ ## Use `Proc.new {}` and not `-> {}`. There's some inconsistency
16
+ ## in how instance_eval works across Ruby versions that will bite
17
+ ## you in the butt otherwise.
18
18
 
19
19
 
20
20
  ## How we access the currently logged in user. This object
21
- ## must respond to #email(string), #id(string), and #name(string)
21
+ ## should respond to #email(String), #id(String),
22
+ ## #created_at(Time) and #name(String)
22
23
  #
23
24
  # config.current_user = Proc.new { current_user }
24
25
 
@@ -41,7 +42,8 @@ RamenRails.config do |config|
41
42
  ## You can add up to 3. Each requires a `title`.
42
43
  ## Each requires a `callback` or an `href`.
43
44
  ## Links w/ `href` will have target="_blank".
44
- ## Callbacks are *strings* not JS functions.
45
+ ## `callback` is a *string*, not a JS closure even
46
+ ## if you override these values in your markup.
45
47
  #
46
48
  # config.custom_links = [
47
49
  # {
@@ -139,7 +139,7 @@ module RamenRails
139
139
  obj[:manual_opt_in] = manual_opt_in
140
140
  obj[:return_url] = return_url
141
141
  obj[:return_label] = return_label
142
-
142
+
143
143
  user = ramen_user_object
144
144
 
145
145
  obj[:user][:id] = user.id if user.respond_to?(:id) && user.id.present?
@@ -147,6 +147,10 @@ module RamenRails
147
147
  [:email, :name].each do |attr|
148
148
  obj[:user][attr] = user.send(attr) if user.respond_to?(attr) && user.send(attr).present?
149
149
  end
150
+
151
+ if user.respond_to?(:created_at) && user.send(:created_at).present?
152
+ obj[:user][:created_at] = user.send(:created_at).to_i
153
+ end
150
154
 
151
155
  obj[:user][:value] = ramen_user_value if ramen_user_value.present?
152
156
  obj[:user][:labels] = ramen_user_labels unless ramen_user_labels.nil?
@@ -1,3 +1,3 @@
1
1
  module RamenRails
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -40,6 +40,35 @@ 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 "with a value proc set" do
44
+ before :each do |c|
45
+ @dummy.current_user.value = 1000
46
+ RamenRails.config do |c|
47
+ c.current_user_value = Proc.new { current_user.value }
48
+ end
49
+ end
50
+
51
+ it "should include value in output" do
52
+ filter = RamenRails::RamenAfterFilter.filter(@dummy)
53
+
54
+ expect(@dummy.response.body).to include("value")
55
+ end
56
+
57
+ end
58
+
59
+ context "that responds to created_at" do
60
+ before :each do
61
+ @time = Time.new(2014, 11, 10)
62
+ @dummy.current_user.created_at = @time
63
+ end
64
+
65
+ it "should include created_at in output" do
66
+ filter = RamenRails::RamenAfterFilter.filter(@dummy)
67
+ expect(@dummy.response.body).to include("created_at")
68
+ expect(@dummy.response.body).to include(@time.to_i.to_s)
69
+ end
70
+ end
71
+
43
72
  it "should attach tag" do
44
73
  Timecop.freeze do
45
74
  ts = Time.now.to_i
@@ -50,8 +79,10 @@ describe 'After filter' do
50
79
 
51
80
  expect(@dummy.response.body).to_not include(auth_hash)
52
81
  expect(@dummy.response.body).to include(ts_auth_hash)
82
+ expect(@dummy.response.body).to_not include("value")
53
83
  expect(@dummy.response.body).to include("script")
54
84
  expect(@dummy.response.body).to include("Angilly")
85
+ expect(@dummy.response.body).to_not include("created_at")
55
86
  expect(@dummy.response.body).to include("hiryan.com")
56
87
  expect(@dummy.response.body).to_not include("company")
57
88
  expect(@dummy.response.body).to_not include("custom_links")
@@ -88,6 +119,7 @@ describe 'After filter' do
88
119
  expect(@dummy.response.body).to include("script")
89
120
  expect(@dummy.response.body).to include("Angilly")
90
121
  expect(@dummy.response.body).to include("hiryan.com")
122
+ expect(@dummy.response.body).to_not include("created_at")
91
123
  expect(@dummy.response.body).to_not include("company")
92
124
  expect(@dummy.response.body).to include("custom_links")
93
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramen-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Angilly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack