action_interceptor 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODI1YzZmYmQ1MjU4YjUwY2IwMmJkZTUyNjdiNzVmMDIxMTg4OWYzMg==
5
- data.tar.gz: !binary |-
6
- M2E5NTczN2RkZWNiZGQxNjgzMzhiNGZmODYyNWM0ZjAxZjBhYWI3Nw==
2
+ SHA1:
3
+ metadata.gz: 91fc5da27aa7c29f7251f8e2eab3118ff37a276a
4
+ data.tar.gz: 2981fdd570f8d5ef6aacecfcb61152943f791d02
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MzNkODA1MWQ4NTQ2YWIwOWRiZGM0NzFjZDRlMWI4YTRlYjNhZDM4Y2Y3YmJi
10
- MTk0NDE0NWViZjIyN2ViYjlkYzE5NzNhZmUxNzI0NTVkN2UxOGQ4ZjM3YzBl
11
- YWViMWIxZjBlZWNhMzJlZDlkMzQzOTM1ZmEzOGE3Y2FjYzg4OGE=
12
- data.tar.gz: !binary |-
13
- MTVhN2IyYjFkYTA2YzgwNWZkYTg4OTg5YjU2NjRhYTY1NzUwMjVkMDkyYzQ4
14
- YzczMGFjNDhmNjdmYWU0MTE2NTQ3NTFjOGVlM2ZkYmFjODlhZTcxZmI3OWY1
15
- MTMyOGZhMDc1ZWQ0ZDg5OGVhNDg4ZWNjYjZjODBlMDVhYzgwZWU=
6
+ metadata.gz: 10a8bc701038b757e287fef7c14970f5dacbdb4b836d6599dce8327e1a9a50dbb00cf241c05e92ab94000a1660753dddd7ca92a8c95af4090c30a92e437151db
7
+ data.tar.gz: 21f27ea5f58e8ac0d25d1de9278510b286a62bb6a60441bd82a3ea890d88eb9e3687412e8e02dd24100268865a0ae2580d422af743160c42848c3a3e581c3eed
@@ -2,8 +2,8 @@ require 'action_interceptor/engine'
2
2
 
3
3
  module ActionInterceptor
4
4
  def self.intercepted_url_key(key = nil)
5
- @intercepted_url_key = key unless key.blank?
6
- @intercepted_url_key || :r
5
+ @intercepted_url_key = key.to_s unless key.blank?
6
+ @intercepted_url_key || 'r'
7
7
  end
8
8
 
9
9
  def self.override_url_options(bool = nil)
@@ -3,9 +3,7 @@ require 'action_interceptor/encryptor'
3
3
  require 'action_interceptor/undefined_interceptor'
4
4
 
5
5
  module ActionInterceptor
6
- module Controller
7
-
8
- include Common
6
+ module ActionController
9
7
 
10
8
  def self.included(base)
11
9
  base.class_attribute :is_interceptor, :use_interceptor,
@@ -49,6 +47,12 @@ module ActionInterceptor
49
47
  session.delete(ActionInterceptor.intercepted_url_key)
50
48
  end
51
49
 
50
+ private
51
+
52
+ def _compute_redirect_to_location(options)
53
+ url_for(super)
54
+ end
55
+
52
56
  module ClassMethods
53
57
 
54
58
  def interceptor(*interceptor_names, &block)
@@ -159,4 +163,4 @@ module ActionInterceptor
159
163
  end
160
164
  end
161
165
 
162
- ActionController::Base.send :include, ActionInterceptor::Controller
166
+ ActionController::Base.send :include, ActionInterceptor::ActionController
@@ -1,5 +1,5 @@
1
1
  module ActionInterceptor
2
- module Mailer
2
+ module ActionMailer
3
3
 
4
4
  def self.included(base)
5
5
  base.helper_method :use_interceptor, :use_interceptor=
@@ -18,4 +18,4 @@ module ActionInterceptor
18
18
  end
19
19
  end
20
20
 
21
- ActionMailer::Base.send :include, ActionInterceptor::Mailer
21
+ ActionMailer::Base.send :include, ActionInterceptor::ActionMailer
@@ -1,16 +1,23 @@
1
+ require 'action_interceptor/action_controller'
2
+
1
3
  module ActionInterceptor
2
4
  module Common
3
5
 
4
- def url_for(options = {})
5
- url = super
6
+ def self.included(base)
7
+ base.alias_method_chain :url_for, :interceptor
8
+ end
9
+
10
+ def url_for_with_interceptor(options = {})
11
+ url = url_for_without_interceptor(options)
6
12
  return url unless use_interceptor
7
13
 
8
14
  @interceptor_url_for_hash ||= is_interceptor ? \
9
- intercepted_url_hash : current_url_hash
15
+ intercepted_url_hash : \
16
+ current_url_hash
10
17
 
11
18
  uri = URI(url)
12
- new_query = URI.decode_www_form(uri.query || '') + \
13
- @interceptor_url_for_hash.to_a
19
+ new_query = Hash[URI.decode_www_form(uri.query || '')]
20
+ .merge(@interceptor_url_for_hash)
14
21
  uri.query = URI.encode_www_form(new_query)
15
22
  uri.to_s
16
23
  end
@@ -59,3 +66,8 @@ module ActionInterceptor
59
66
 
60
67
  end
61
68
  end
69
+
70
+ ActionController::Base.send :include, ActionInterceptor::Common
71
+ ActionView::Base.send :include, ActionInterceptor::Common
72
+ ActionView::RoutingUrlFor.send :include, ActionInterceptor::Common \
73
+ if defined?(ActionView::RoutingUrlFor)
@@ -1,6 +1,6 @@
1
- require 'action_interceptor/controller'
2
- require 'action_interceptor/mailer'
3
- require 'action_interceptor/view'
1
+ require 'action_interceptor/common'
2
+ require 'action_interceptor/action_controller'
3
+ require 'action_interceptor/action_mailer'
4
4
 
5
5
  module ActionInterceptor
6
6
  class Engine < ::Rails::Engine
@@ -1,4 +1,3 @@
1
1
  module ActionInterceptor
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
4
-
@@ -1,31 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module ActionInterceptor
4
- describe Controller do
4
+ describe ActionController do
5
5
 
6
6
  it 'modifies ActionController::Base' do
7
- expect(ActionController::Base).to respond_to(:is_interceptor)
8
- expect(ActionController::Base).to respond_to(:use_interceptor)
9
- expect(ActionController::Base).to respond_to(:interceptor_filters)
10
- expect(ActionController::Base.is_interceptor).to eq(false)
11
- expect(ActionController::Base.interceptor_filters).to be_a(Hash)
7
+ expect(::ActionController::Base).to respond_to(:is_interceptor)
8
+ expect(::ActionController::Base).to respond_to(:use_interceptor)
9
+ expect(::ActionController::Base).to respond_to(:interceptor_filters)
10
+ expect(::ActionController::Base.is_interceptor).to eq(false)
11
+ expect(::ActionController::Base.interceptor_filters).to be_a(Hash)
12
12
 
13
- expect(ActionController::Base).to respond_to(:interceptor)
14
- expect(ActionController::Base).to respond_to(:skip_interceptor)
15
- expect(ActionController::Base).to respond_to(:acts_as_interceptor)
13
+ expect(::ActionController::Base).to respond_to(:interceptor)
14
+ expect(::ActionController::Base).to respond_to(:skip_interceptor)
15
+ expect(::ActionController::Base).to respond_to(:acts_as_interceptor)
16
16
 
17
- expect(ActionController::Base.new.respond_to?(
17
+ expect(::ActionController::Base.new.respond_to?(
18
18
  :current_page?, true)).to eq(true)
19
- expect(ActionController::Base.new.respond_to?(
19
+ expect(::ActionController::Base.new.respond_to?(
20
20
  :current_url, true)).to eq(true)
21
- expect(ActionController::Base.new.respond_to?(
21
+ expect(::ActionController::Base.new.respond_to?(
22
22
  :current_url_hash, true)).to eq(true)
23
- expect(ActionController::Base.new.respond_to?(
24
- :url_for, true)).to eq(true)
25
- expect(ActionController::Base.new.respond_to?(
26
- :with_interceptor, true)).to eq(true)
27
- expect(ActionController::Base.new.respond_to?(
28
- :without_interceptor, true)).to eq(true)
29
23
  end
30
24
 
31
25
  it 'modifies classes that act_as_interceptor' do
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module ActionInterceptor
4
- describe Mailer do
4
+ describe ActionMailer do
5
5
 
6
6
  it 'modifies ActionMailer::Base' do
7
- mailer = ActionMailer::Base.send(:new)
7
+ mailer = ::ActionMailer::Base.send(:new)
8
8
  expect(mailer.respond_to?(:use_interceptor, true)).to eq(true)
9
9
  expect(mailer.respond_to?(:use_interceptor=, true)).to eq(true)
10
10
 
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ module ActionInterceptor
4
+ describe Common do
5
+
6
+ it 'modifies ActionController::Base' do
7
+ expect(::ActionController::Base.new.respond_to?(
8
+ :url_for, true)).to eq(true)
9
+ expect(::ActionController::Base.new.respond_to?(
10
+ :with_interceptor, true)).to eq(true)
11
+ expect(::ActionController::Base.new.respond_to?(
12
+ :without_interceptor, true)).to eq(true)
13
+ end
14
+
15
+ it 'modifies ActionView::Base' do
16
+ expect(::ActionView::Base.new.respond_to?(
17
+ :url_for, true)).to eq(true)
18
+ expect(::ActionView::Base.new.respond_to?(
19
+ :with_interceptor, true)).to eq(true)
20
+ expect(::ActionView::Base.new.respond_to?(
21
+ :without_interceptor, true)).to eq(true)
22
+ end
23
+
24
+ end
25
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe ActionInterceptor do
4
4
  it 'must be configurable' do
5
- expect(ActionInterceptor.intercepted_url_key).to eq(:dummy_key)
5
+ expect(ActionInterceptor.intercepted_url_key).to eq('dummy_key')
6
6
  expect(ActionInterceptor.override_url_options).to eq(true)
7
7
  expect(ActionInterceptor.interceptors.keys).to include(:registration)
8
8
 
@@ -14,7 +14,7 @@ describe ActionInterceptor do
14
14
  interceptor :my_name, &my_block
15
15
  end
16
16
 
17
- expect(ActionInterceptor.intercepted_url_key).to eq(:my_key)
17
+ expect(ActionInterceptor.intercepted_url_key).to eq('my_key')
18
18
  expect(ActionInterceptor.override_url_options).to eq(false)
19
19
  expect(ActionInterceptor.interceptors).to include({:my_name => my_block})
20
20
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_interceptor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Soares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-21 00:00:00.000000000 Z
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Action Interceptor provides controllers that require users to perform
@@ -66,14 +66,13 @@ files:
66
66
  - Rakefile
67
67
  - config/initializers/action_interceptor.rb
68
68
  - lib/action_interceptor.rb
69
+ - lib/action_interceptor/action_controller.rb
70
+ - lib/action_interceptor/action_mailer.rb
69
71
  - lib/action_interceptor/common.rb
70
- - lib/action_interceptor/controller.rb
71
72
  - lib/action_interceptor/encryptor.rb
72
73
  - lib/action_interceptor/engine.rb
73
- - lib/action_interceptor/mailer.rb
74
74
  - lib/action_interceptor/undefined_interceptor.rb
75
75
  - lib/action_interceptor/version.rb
76
- - lib/action_interceptor/view.rb
77
76
  - lib/tasks/action_interceptor_tasks.rake
78
77
  - spec/dummy/README.md
79
78
  - spec/dummy/Rakefile
@@ -111,10 +110,10 @@ files:
111
110
  - spec/dummy/public/422.html
112
111
  - spec/dummy/public/500.html
113
112
  - spec/dummy/public/favicon.ico
114
- - spec/lib/action_interceptor/controller_spec.rb
113
+ - spec/lib/action_interceptor/action_controller_spec.rb
114
+ - spec/lib/action_interceptor/action_mailer_spec.rb
115
+ - spec/lib/action_interceptor/common_spec.rb
115
116
  - spec/lib/action_interceptor/encryptor_spec.rb
116
- - spec/lib/action_interceptor/mailer_spec.rb
117
- - spec/lib/action_interceptor/view_spec.rb
118
117
  - spec/lib/action_interceptor_spec.rb
119
118
  - spec/spec_helper.rb
120
119
  homepage: http://github.com/openstax/action_interceptor
@@ -127,12 +126,12 @@ require_paths:
127
126
  - lib
128
127
  required_ruby_version: !ruby/object:Gem::Requirement
129
128
  requirements:
130
- - - ! '>='
129
+ - - ">="
131
130
  - !ruby/object:Gem::Version
132
131
  version: '0'
133
132
  required_rubygems_version: !ruby/object:Gem::Requirement
134
133
  requirements:
135
- - - ! '>='
134
+ - - ">="
136
135
  - !ruby/object:Gem::Version
137
136
  version: '0'
138
137
  requirements: []
@@ -178,9 +177,9 @@ test_files:
178
177
  - spec/dummy/public/favicon.ico
179
178
  - spec/dummy/Rakefile
180
179
  - spec/dummy/README.md
181
- - spec/lib/action_interceptor/controller_spec.rb
180
+ - spec/lib/action_interceptor/action_controller_spec.rb
181
+ - spec/lib/action_interceptor/action_mailer_spec.rb
182
+ - spec/lib/action_interceptor/common_spec.rb
182
183
  - spec/lib/action_interceptor/encryptor_spec.rb
183
- - spec/lib/action_interceptor/mailer_spec.rb
184
- - spec/lib/action_interceptor/view_spec.rb
185
184
  - spec/lib/action_interceptor_spec.rb
186
185
  - spec/spec_helper.rb
@@ -1,11 +0,0 @@
1
- require 'action_interceptor/common'
2
-
3
- module ActionInterceptor
4
- module View
5
-
6
- include Common
7
-
8
- end
9
- end
10
-
11
- ActionView::Base.send :include, ActionInterceptor::View
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ActionInterceptor
4
- describe View do
5
-
6
- it 'modifies ActionView::Base' do
7
- expect(ActionView::Base.new.respond_to?(
8
- :url_for, true)).to eq(true)
9
- expect(ActionView::Base.new.respond_to?(
10
- :with_interceptor, true)).to eq(true)
11
- expect(ActionView::Base.new.respond_to?(
12
- :without_interceptor, true)).to eq(true)
13
- end
14
-
15
- end
16
- end