ramen-rails 0.6.4 → 0.7.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: b4b6bf2f436424841a968e23d07e9f55a873cb40
4
- data.tar.gz: 496743ad914cfc6b572e5c5d1e02c49c67f988b4
3
+ metadata.gz: 292dedebe37ea6d43abc9f6da0c8391936fd35bc
4
+ data.tar.gz: da2d1273bf8b03e205b8b790b3c932fa7fbb7fd5
5
5
  SHA512:
6
- metadata.gz: 5c79e791ce639e5704f6311495d962b008e486d2efc43d4e882315b93acfdfe824c27554d7c9c9eea339842a46e641a0587fe7a9fa07cc6af8fb0dde7fdc7929
7
- data.tar.gz: 5faf2cd7d1f02093d11729d8445780218cbd714024112dae4063890713e3715d0e81c7fbc4523dd6e8ddbe2e3e6809a7ae8cc25e0498f92097b81b19d78f78ad
6
+ metadata.gz: 17854a7e4ae7c4136dcc1651143fa832f615b082a4bb75e9e9e6408aa8b481352cc11a6eec68a6047983decf408a8bd888de9c269e23faa12c6b8272ae6c0da2
7
+ data.tar.gz: 3b338a49b73ca2a7f6879262ab4d0d37cef2228fca5cb428f7bf86a153787126b5b79e95fec9d82e8ffcf6e21d6fbb12ee136a6b018b5c96b9ed0d9800d89522
data/CHANGELOG CHANGED
@@ -38,3 +38,10 @@ it.
38
38
  Version 0.6.4
39
39
  Run #to_s on name, email, id (Customer) and url, name, id (Company) to deal with (among other things)
40
40
  how MongoDB BSON::ObjectIds are serialized
41
+
42
+ Version 0.7.0
43
+ Added ability to set `config.enabled_environments` so that the after_filter will only be ran
44
+ on selected environments.
45
+
46
+ Version 0.7.1
47
+ Because we yanked 0.7.0 to update this Changelog :)
@@ -9,6 +9,10 @@ RamenRails.config do |config|
9
9
  # config.organization_secret = "SEKRIT"
10
10
  <%- end -%>
11
11
 
12
+ # Enabled environments
13
+ # Defaults to all environments, but you can limit it to not run
14
+ # in your test environment, for example:
15
+ # config.enabled_environments = ["development", "production"]
12
16
 
13
17
  ## Important note regarding `-> {}` vs. `Proc.new {}`
14
18
  ##
@@ -10,7 +10,8 @@ module RamenRails
10
10
  :return_url,
11
11
  :return_label,
12
12
  :ramen_js_asset_uri,
13
- :custom_links
13
+ :custom_links,
14
+ :enabled_environments
14
15
 
15
16
  def ensure_not_lambda!(v)
16
17
  if v.lambda?
@@ -19,9 +19,12 @@ module RamenRails
19
19
 
20
20
  def self.filter(controller)
21
21
  auto_include_filter = new(controller)
22
- return unless auto_include_filter.include_javascript?
23
-
24
- auto_include_filter.include_javascript!
22
+
23
+ if auto_include_filter.include_javascript?
24
+ auto_include_filter.include_javascript!
25
+ elsif auto_include_filter.disabled_environment?
26
+ auto_include_filter.include_disabled_comment!
27
+ end
25
28
  end
26
29
 
27
30
  attr_reader :controller
@@ -34,14 +37,29 @@ module RamenRails
34
37
  controller.ramen_script_tag_options
35
38
  end
36
39
 
40
+ def include_disabled_comment!
41
+ response.body = response.body.gsub(CLOSING_BODY_TAG, "<!-- Ramen not enabled for environment `#{Rails.env}`. Enabled for: #{RamenRails.config.enabled_environments.inspect} -->" + '\\0')
42
+ end
43
+
37
44
  def include_javascript!
38
45
  response.body = response.body.gsub(CLOSING_BODY_TAG, ramen_script_tag + '\\0')
39
46
  end
40
47
 
48
+ def enabled_environment?
49
+ return true unless RamenRails.config.enabled_environments
50
+
51
+ return RamenRails.config.enabled_environments.map(&:to_s).include?(Rails.env.to_s)
52
+ end
53
+
54
+ def disabled_environment?
55
+ !enabled_environment?
56
+ end
57
+
41
58
  def include_javascript?
42
59
  !ramen_script_tag_called_manually? &&
43
60
  html_content_type? &&
44
61
  response_has_closing_body_tag? &&
62
+ enabled_environment? &&
45
63
  ramen_org_id.present? &&
46
64
  ramen_user_object.present?
47
65
  end
@@ -1,3 +1,3 @@
1
1
  module RamenRails
2
- VERSION = "0.6.4"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -113,6 +113,20 @@ describe 'After filter' do
113
113
  end
114
114
  end
115
115
 
116
+ context "with enabled_environments set to empty" do
117
+ before :each do |c|
118
+ RamenRails.config do |c|
119
+ c.enabled_environments = []
120
+ end
121
+ end
122
+
123
+ it "not render script tag" do
124
+ filter = RamenRails::RamenAfterFilter.filter(@dummy)
125
+ expect(@dummy.response.body).to_not include("ramenSettings")
126
+ expect(@dummy.response.body).to include("Ramen not enabled for environment")
127
+ end
128
+ end
129
+
116
130
  context "with a value proc set" do
117
131
  before :each do |c|
118
132
  @dummy.current_user.set value: 1000
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.6.4
4
+ version: 0.7.1
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-08-05 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack