jump_back 0.2.2 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jump_back/engine.rb +1 -0
  3. data/lib/jump_back/link_back.rb +31 -0
  4. data/lib/jump_back/options_parser.rb +17 -10
  5. data/lib/jump_back/path_finder.rb +36 -0
  6. data/lib/jump_back/redirect_back.rb +2 -6
  7. data/lib/jump_back/return_to_referer.rb +2 -2
  8. data/lib/jump_back/urls.rb +28 -0
  9. data/lib/jump_back/version.rb +1 -1
  10. data/lib/jump_back.rb +3 -0
  11. data/spec/controller/application_controller_spec.rb +4 -19
  12. data/spec/controller/tests_controller_spec.rb +85 -85
  13. data/spec/dummy/app/controllers/tests_controller.rb +12 -12
  14. data/spec/dummy/app/views/tests/blank.html.erb +10 -0
  15. data/spec/dummy/app/views/tests/clear_and_save.html.erb +17 -0
  16. data/spec/dummy/app/views/tests/save.html.erb +10 -0
  17. data/spec/dummy/config/routes.rb +11 -59
  18. data/spec/dummy/db/test.sqlite3 +0 -0
  19. data/spec/dummy/log/development.log +4 -104
  20. data/spec/dummy/log/test.log +275 -18408
  21. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  22. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  23. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  24. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  25. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  26. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  27. data/spec/features/controller_methods_spec.rb +38 -0
  28. data/spec/features/view_helpers_spec.rb +87 -0
  29. metadata +15 -14
  30. data/lib/jump_back/redirection_determiner.rb +0 -14
  31. data/lib/jump_back/referer_interpreter.rb +0 -34
  32. data/spec/dummy/app/views/tests/edit.html.erb +0 -3
  33. data/spec/dummy/app/views/tests/index.html.erb +0 -6
  34. data/spec/dummy/app/views/tests/new.html.erb +0 -6
  35. data/spec/dummy/db/development.sqlite3 +0 -0
  36. data/spec/features/jump_back_feature_spec.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13b46750e5e152338c99ca95598a07da26f2520c
4
- data.tar.gz: bcfc2c6ff049737adca0d7d039ec284e76caae0d
3
+ metadata.gz: 0af5b300967e7ac035f3ebb0cec0c0d12a48f068
4
+ data.tar.gz: 05424a881293b19251376c3cf655eab3e989de54
5
5
  SHA512:
6
- metadata.gz: ae36bde7619da211b1d0277079188c376734124f926ebb65ccce53e5251c742a26ffd37e03651e67e9baea4292f2078ff41be724724fe3ee16c15f35ebc844b0
7
- data.tar.gz: 44ec9bd6e00a0fa7f45c9f43ffe603386ae9b8d4cf2978d5a538613831100c013fc9ce1d255f40db3f9d682fdf3c1778520a15a0a323e6f7c258d5f16c500a8a
6
+ metadata.gz: c63a0123fba02897bae16ede59524a275fe62ccf5d675ccc8167bcf9beb84e4f01791c898f7c6590ade0bad45a9b56e3bdf0c663b5890de5dc9208d94a416fb5
7
+ data.tar.gz: 6ecd0e9ca8aa795a94387134bd01e5239fb69baadbaca72b1f554fc84a658405e5512d0f0facc77111475adca6227711d1365d75449810f7c01f446a0e6fcd96
@@ -7,6 +7,7 @@ module JumpBack
7
7
  end
8
8
  initializer "jump_back.methods" do |app|
9
9
  ApplicationController.send :include, JumpBack::Redirection
10
+ ActionView::Base.send :include, JumpBack::Helpers
10
11
  end
11
12
  end
12
13
  end
@@ -0,0 +1,31 @@
1
+ module JumpBack
2
+
3
+ module Helpers
4
+
5
+ def link_back(name='back', path=root_path, options={})
6
+ args = HelpersArguments.parse(name, path, options, root_path)
7
+ link_to args[:name], PathFinder.new(request, args[:path], args[:jump_back_options]).path, args[:redirect_options]
8
+ end
9
+ end
10
+
11
+ module HelpersArguments
12
+
13
+ def self.parse(name, path, options, root_path)
14
+ if first_arg_is_path?(name, path, root_path)
15
+ options = path if path.is_a? Hash
16
+ path = name
17
+ name = 'back'
18
+ end
19
+ if name.is_a? Hash
20
+ options = name
21
+ name = 'back'
22
+ end
23
+ options = OptionsParser.new(default: root_path, path: path, options: options)
24
+ { name: name, path: options.path, jump_back_options: options.jump_back_options, redirect_options: options.redirect_options }
25
+ end
26
+
27
+ def self.first_arg_is_path?(name, path, root_path)
28
+ Urls.is_url?(name) && (path == root_path || path.is_a?(Hash))
29
+ end
30
+ end
31
+ end
@@ -2,18 +2,25 @@ module JumpBack
2
2
 
3
3
  class OptionsParser
4
4
 
5
- def self.parse(path, options, default)
6
- if path.is_a? Hash
7
- options = path
8
- path = default
5
+ attr_reader :path, :redirect_options, :jump_back_options
6
+
7
+ def initialize(options)
8
+ @path = parse(options)[:path]
9
+ @redirect_options = parse(options)[:redirect_options]
10
+ @jump_back_options = parse(options)[:jump_back_options]
11
+ end
12
+
13
+ def parse(options)
14
+ return @options if @options
15
+
16
+ if options[:path].is_a? Hash
17
+ options[:options] = options[:path]
18
+ options[:path] = options[:default]
9
19
  end
10
20
 
11
- jump_back_options = { offsite: options.delete(:offsite) }
12
- {
13
- redirect_options: options,
14
- jump_back_options: jump_back_options,
15
- path: path
16
- }
21
+ options[:jump_back_options] = { offsite: options[:options].delete(:offsite) }
22
+ options[:redirect_options] = options.delete(:options)
23
+ @options = options
17
24
  end
18
25
  end
19
26
  end
@@ -0,0 +1,36 @@
1
+ module JumpBack
2
+
3
+ class PathFinder
4
+ attr_reader :path
5
+
6
+ def initialize(request, path, options)
7
+ @uri = Urls.uri(request.env["HTTP_REFERER"])
8
+ @path = determine_path(request, path, options)
9
+ end
10
+
11
+ def redirect_back?(request, options)
12
+ has_referer?(request) ? is_local?(request, options) ? true : false : false
13
+ end
14
+
15
+ def has_referer?(request)
16
+ !request.env["HTTP_REFERER"].blank? and request.env["HTTP_REFERER"] != request.env["REQUEST_URI"]
17
+ end
18
+
19
+ def is_local?(request, options)
20
+ return true if options[:offsite]
21
+ !(host && host != request.host)
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :uri
27
+
28
+ def determine_path(request, path, options)
29
+ redirect_back?(request, options) ? :back : path
30
+ end
31
+
32
+ def host
33
+ uri.host if uri
34
+ end
35
+ end
36
+ end
@@ -1,14 +1,10 @@
1
- require 'jump_back/referer_interpreter'
2
- require 'jump_back/redirection_determiner'
3
- require 'jump_back/options_parser'
4
-
5
1
  module JumpBack
6
2
 
7
3
  module Redirection
8
4
 
9
5
  def redirect_back(path=root_path, options={})
10
- parsed_args = OptionsParser.parse(path, options, root_path)
11
- redirect_to RedirectionDeterminer.new(request, parsed_args[:path], parsed_args[:jump_back_options]).path, parsed_args[:redirect_options]
6
+ options = OptionsParser.new(path: path, options: options, default: root_path)
7
+ redirect_to PathFinder.new(request, options.path, options.jump_back_options).path, options.redirect_options
12
8
  end
13
9
  end
14
10
  end
@@ -9,8 +9,8 @@ module JumpBack
9
9
  end
10
10
 
11
11
  def return_to_referer(path=root_path, options={})
12
- parsed_args = OptionsParser.parse(path, options, root_path)
13
- session[:jump_back_stored_referer] ? redirect_to(clear_referer, parsed_args[:redirect_options]) : redirect_to(parsed_args[:path], parsed_args[:redirect_options])
12
+ options = OptionsParser.new(path: path, options: options, default: root_path)
13
+ session[:jump_back_stored_referer] ? redirect_to(clear_referer, options.redirect_options) : redirect_to(options.path, options.redirect_options)
14
14
  end
15
15
 
16
16
  def clear_referer
@@ -0,0 +1,28 @@
1
+ module JumpBack
2
+
3
+ module Urls
4
+
5
+ def self.is_url?(string)
6
+ is_uri?(string) || is_path?(string)
7
+ end
8
+
9
+ def self.uri(string)
10
+ URI.parse string if is_uri? string
11
+ end
12
+
13
+ def self.is_uri?(string)
14
+ uri = URI.parse string
15
+ %w( http https ).include? uri.scheme
16
+ rescue URI::BadURIError
17
+ false
18
+ rescue URI::InvalidURIError
19
+ false
20
+ end
21
+
22
+ def self.is_path?(string)
23
+ !!(Rails.application.routes.recognize_path string)
24
+ rescue ActionController::RoutingError
25
+ false
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module JumpBack
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/jump_back.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'jump_back/engine'
2
2
  require 'jump_back/redirect_back'
3
3
  require 'jump_back/return_to_referer'
4
+ require 'jump_back/path_finder'
5
+ require 'jump_back/link_back'
6
+ require 'jump_back/urls'
4
7
 
5
8
  module JumpBack
6
9
  end
@@ -2,35 +2,20 @@ describe ApplicationController do
2
2
 
3
3
  describe 'jump_back methods' do
4
4
 
5
- it 'should have the redirect_back method' do
5
+ it 'has the redirect_back method' do
6
6
  expect(ApplicationController.new).to respond_to :redirect_back
7
7
  end
8
8
 
9
- it 'should have the save_referer method' do
9
+ it 'has the save_referer method' do
10
10
  expect(ApplicationController.new).to respond_to :save_referer
11
11
  end
12
12
 
13
- it 'should have the return_to_referer method' do
13
+ it 'has the return_to_referer method' do
14
14
  expect(ApplicationController.new).to respond_to :return_to_referer
15
15
  end
16
16
 
17
- it 'should have the clear_referer method' do
17
+ it 'has the clear_referer method' do
18
18
  expect(ApplicationController.new).to respond_to :clear_referer
19
19
  end
20
20
  end
21
-
22
- describe 'private jump_back classes' do
23
-
24
- it 'should not have the OptionsParser class' do
25
- expect { ApplicationController::OptionsParser.new }.to raise_error
26
- end
27
-
28
- it 'should not have the RefererInterpreter class' do
29
- expect { ApplicationController::RefererInterpreter.new }.to raise_error
30
- end
31
-
32
- it 'should not have the RedirectionDeterminer class' do
33
- expect { ApplicationController::RedirectionDeterminer.new }.to raise_error
34
- end
35
- end
36
21
  end
@@ -2,79 +2,79 @@ describe TestsController, type: :controller do
2
2
 
3
3
  describe 'redirect_back' do
4
4
 
5
- it 'should redirect to default with no referer and no arguments' do
6
- post :create
5
+ it 'redirects to default with no referer and no arguments' do
6
+ post :redirect_with_options
7
7
  expect(response).to redirect_to(root_path)
8
8
  end
9
9
 
10
- it 'should redirect to the supplied path with no referer' do
11
- delete :destroy, id: 1
12
- expect(response).to redirect_to(new_test_path)
10
+ it 'redirects to the supplied path with no referer' do
11
+ delete :clear_and_redirect
12
+ expect(response).to redirect_to(save_path)
13
13
  end
14
14
 
15
- it 'should redirect back with a referer' do
16
- @request.env['HTTP_REFERER'] = test_path(1)
17
- post :create
18
- expect(response).to redirect_to(test_path(1))
19
- delete :destroy, id: 2
20
- expect(response).to redirect_to(test_path(1))
15
+ it 'redirects back with a referer' do
16
+ @request.env['HTTP_REFERER'] = return_with_path_path
17
+ post :redirect_with_options
18
+ expect(response).to redirect_to(return_with_path_path)
19
+ delete :clear_and_redirect
20
+ expect(response).to redirect_to(return_with_path_path)
21
21
  end
22
22
 
23
- it 'should not redirect back when the referer is offsite' do
23
+ it 'doesn\'t redirect back when the referer is offsite' do
24
24
  @request.env['HTTP_REFERER'] = 'http://rubyonrails.org/'
25
- post :create
25
+ post :redirect_with_options
26
26
  expect(response).to redirect_to(root_path)
27
- delete :destroy, id: 1
28
- expect(response).to redirect_to(new_test_path)
27
+ delete :clear_and_redirect
28
+ expect(response).to redirect_to(save_path)
29
29
  end
30
30
 
31
- it 'should redirect back when referer is offsite with offsite set to true' do
31
+ it 'redirects back when referer is offsite with offsite set to true' do
32
32
  @request.env['HTTP_REFERER'] = 'http://rubyonrails.org/'
33
- get :offsite_with_default
33
+ get :offsite_with_path
34
34
  expect(response).to redirect_to('http://rubyonrails.org/')
35
35
  end
36
36
 
37
- it 'should redirect back when referer is offsite with offsite set to true with no path argument' do
37
+ it 'redirects back when referer is offsite with offsite set to true with no path argument' do
38
38
  @request.env['HTTP_REFERER'] = 'http://rubyonrails.org/'
39
- get :offsite_without_default
39
+ get :offsite
40
40
  expect(response).to redirect_to('http://rubyonrails.org/')
41
41
  end
42
42
 
43
- it 'should work normally with no referer if offsite is true' do
44
- get :offsite_with_default
45
- expect(response).to redirect_to(new_test_path)
46
- get :offsite_without_default
43
+ it 'works normally with no referer if offsite is true' do
44
+ get :offsite_with_path
45
+ expect(response).to redirect_to(save_path)
46
+ get :offsite
47
47
  expect(response).to redirect_to(root_path)
48
48
  end
49
49
 
50
- it 'should pass additional options to redirect_to' do
51
- post :create
50
+ it 'passes additional options to redirect_to' do
51
+ post :redirect_with_options
52
52
  expect(flash[:notice]).to eq('Created!')
53
53
  expect(response.status).to eq(301)
54
54
  end
55
55
 
56
- it 'should pass additional options with offsite set to true with default specified and a referer' do
56
+ it 'passes additional options with offsite set to true with path specified and a referer' do
57
57
  @request.env['HTTP_REFERER'] = 'http://rubyonrails.org/'
58
- get :offsite_with_default
58
+ get :offsite_with_path
59
59
  expect(response).to redirect_to('http://rubyonrails.org/')
60
60
  expect(flash[:alert]).to eq('Offsite with default!')
61
61
  end
62
62
 
63
- it 'should pass additional options with offsite set to true without default specified and a referer' do
63
+ it 'passes additional options with offsite set to true without path specified and a referer' do
64
64
  @request.env['HTTP_REFERER'] = 'http://rubyonrails.org/'
65
- get :offsite_without_default
65
+ get :offsite
66
66
  expect(response).to redirect_to('http://rubyonrails.org/')
67
67
  expect(flash[:alert]).to eq('Offsite without default!')
68
68
  end
69
69
 
70
- it 'should pass additional options with offsite set to true with default specified and no referer' do
71
- get :offsite_with_default
72
- expect(response).to redirect_to(new_test_path)
70
+ it 'passes additional options with offsite set to true with path specified and no referer' do
71
+ get :offsite_with_path
72
+ expect(response).to redirect_to(save_path)
73
73
  expect(flash[:alert]).to eq('Offsite with default!')
74
74
  end
75
75
 
76
- it 'should pass additional options with offsite set to true without default specified and no referer' do
77
- get :offsite_without_default
76
+ it 'passes additional options with offsite set to true without path specified and no referer' do
77
+ get :offsite
78
78
  expect(response).to redirect_to(root_path)
79
79
  expect(flash[:alert]).to eq('Offsite without default!')
80
80
  end
@@ -82,83 +82,83 @@ describe TestsController, type: :controller do
82
82
 
83
83
  describe 'save_referer' do
84
84
 
85
- it 'should save the referer in the session' do
86
- @request.env['HTTP_REFERER'] = test_path(1)
87
- get :new
88
- expect(session[:jump_back_stored_referer]).to eq(test_path(1))
85
+ it 'saves the referer in the session' do
86
+ @request.env['HTTP_REFERER'] = return_with_path_path
87
+ get :save
88
+ expect(session[:jump_back_stored_referer]).to eq(return_with_path_path)
89
89
  end
90
90
 
91
- it 'should not overwrite the referer once saved' do
92
- @request.env['HTTP_REFERER'] = test_path(1)
93
- get :new
94
- @request.env['HTTP_REFERER'] = new_test_path
95
- get :new
96
- expect(session[:jump_back_stored_referer]).to eq(test_path(1))
91
+ it 'doesn\'t overwrite the referer once saved' do
92
+ @request.env['HTTP_REFERER'] = return_with_path_path
93
+ get :save
94
+ @request.env['HTTP_REFERER'] = save_path
95
+ get :save
96
+ expect(session[:jump_back_stored_referer]).to eq(return_with_path_path)
97
97
  end
98
98
  end
99
99
 
100
100
  describe 'clear_referer' do
101
101
 
102
- it 'should remove the stored referer' do
103
- @request.env['HTTP_REFERER'] = test_path(1)
104
- get :new
105
- expect(session[:jump_back_stored_referer]).to eq(test_path(1))
106
- delete :destroy, id: 1
102
+ it 'removes the stored referer' do
103
+ @request.env['HTTP_REFERER'] = return_with_path_path
104
+ get :save
105
+ expect(session[:jump_back_stored_referer]).to eq(return_with_path_path)
106
+ delete :clear_and_redirect
107
107
  expect(session[:jump_back_stored_referer]).to be_nil
108
108
  end
109
109
 
110
- it 'should remove the stored referer so it can be written' do
111
- @request.env['HTTP_REFERER'] = test_path(1)
112
- get :new
113
- expect(session[:jump_back_stored_referer]).to eq(test_path(1))
114
- @request.env['HTTP_REFERER'] = new_test_path
115
- get :edit, id: 1
116
- expect(session[:jump_back_stored_referer]).to eq(new_test_path)
110
+ it 'removes the stored referer so it can be written' do
111
+ @request.env['HTTP_REFERER'] = return_with_path_path
112
+ get :save
113
+ expect(session[:jump_back_stored_referer]).to eq(return_with_path_path)
114
+ @request.env['HTTP_REFERER'] = save_path
115
+ get :clear_and_save
116
+ expect(session[:jump_back_stored_referer]).to eq(save_path)
117
117
  end
118
118
  end
119
119
 
120
120
  describe 'return_to_referer' do
121
- it 'should redirect to saved referer' do
122
- @request.env['HTTP_REFERER'] = test_path(1)
123
- get :new
124
- put :update, id: 1
125
- expect(response).to redirect_to(test_path(1))
126
- end
127
-
128
- it 'should redirect to saved referer even with actions in between' do
129
- @request.env['HTTP_REFERER'] = test_path(1)
130
- get :new
131
- post :create
132
- put :update, id: 1
133
- expect(response).to redirect_to(test_path(1))
134
- end
135
-
136
- it 'should delete the stored referer' do
137
- @request.env['HTTP_REFERER'] = test_path(1)
138
- get :new
139
- expect(session[:jump_back_stored_referer]).to eq(test_path(1))
140
- put :update, id: 1
121
+ it 'redirects to saved referer' do
122
+ @request.env['HTTP_REFERER'] = return_with_path_path
123
+ get :save
124
+ put :return_with_options
125
+ expect(response).to redirect_to(return_with_path_path)
126
+ end
127
+
128
+ it 'redirects to saved referer even with actions in between' do
129
+ @request.env['HTTP_REFERER'] = return_with_path_path
130
+ get :save
131
+ post :redirect_with_options
132
+ put :return_with_options
133
+ expect(response).to redirect_to(return_with_path_path)
134
+ end
135
+
136
+ it 'deletes the stored referer' do
137
+ @request.env['HTTP_REFERER'] = return_with_path_path
138
+ get :save
139
+ expect(session[:jump_back_stored_referer]).to eq(return_with_path_path)
140
+ put :return_with_options
141
141
  expect(session[:jump_back_stored_referer]).to be_nil
142
142
  end
143
143
 
144
- it 'should redirect to default with no referer and no arguments' do
145
- put :update, id: 1
144
+ it 'redirects to default with no referer and no arguments' do
145
+ put :return_with_options
146
146
  expect(response).to redirect_to(root_path)
147
147
  end
148
148
 
149
- it 'should redirect to argument with no referer' do
150
- get :show, id: 1
151
- expect(response).to redirect_to(new_test_path)
149
+ it 'redirects to argument with no referer' do
150
+ get :return_with_path
151
+ expect(response).to redirect_to(save_path)
152
152
  end
153
153
 
154
- it 'should pass options to redirect_to with a default path specified' do
155
- get :show, id: 1
154
+ it 'passes options to redirect_to with a path specified' do
155
+ get :return_with_path
156
156
  expect(flash[:alert]).to eq('Go away!')
157
157
  expect(response.status).to eq(301)
158
158
  end
159
159
 
160
- it 'should pass options to redirect_to without a default path specified' do
161
- put :update, id: 1
160
+ it 'passes options to redirect_to without a path specified' do
161
+ put :return_with_options
162
162
  expect(flash[:notice]).to eq('Updated!')
163
163
  expect(response.status).to eq(302)
164
164
  end
@@ -1,38 +1,38 @@
1
1
  class TestsController < ApplicationController
2
- def index
2
+ def blank
3
3
  end
4
4
 
5
- def show
6
- return_to_referer new_test_path, alert: 'Go away!', status: 301
5
+ def return_with_path
6
+ return_to_referer save_path, alert: 'Go away!', status: 301
7
7
  end
8
8
 
9
- def new
9
+ def save
10
10
  save_referer
11
11
  end
12
12
 
13
- def create
13
+ def redirect_with_options
14
14
  redirect_back notice: 'Created!', status: :moved_permanently
15
15
  end
16
16
 
17
- def edit
17
+ def clear_and_save
18
18
  clear_referer
19
19
  save_referer
20
20
  end
21
21
 
22
- def update
22
+ def return_with_options
23
23
  return_to_referer notice: 'Updated!', status: 302
24
24
  end
25
25
 
26
- def destroy
26
+ def clear_and_redirect
27
27
  clear_referer
28
- redirect_back new_test_path
28
+ redirect_back save_path
29
29
  end
30
30
 
31
- def offsite_with_default
32
- redirect_back new_test_path, offsite: true, alert: 'Offsite with default!'
31
+ def offsite_with_path
32
+ redirect_back save_path, offsite: true, alert: 'Offsite with default!'
33
33
  end
34
34
 
35
- def offsite_without_default
35
+ def offsite
36
36
  redirect_back offsite: true, alert: 'Offsite without default!'
37
37
  end
38
38
  end
@@ -0,0 +1,10 @@
1
+ Blank Path
2
+ <%= form_tag return_with_options_path, method: :put do %>
3
+ <%= submit_tag 'Put to return_with_options' %>
4
+ <% end %>
5
+
6
+ <%= link_to 'Go to save page', save_path %>
7
+
8
+ <%= link_back clear_and_save_path %>
9
+
10
+ <%= link_back 'A back link', save_path %>
@@ -0,0 +1,17 @@
1
+ Clear and Save Path
2
+
3
+ <%= link_to 'Go to save page', save_path %>
4
+
5
+ <%= link_back 'Go back from whence you came!' %>
6
+
7
+ <%= link_back class: 'red' %>
8
+
9
+ <%= link_back 'Just a name!', id: 'just-name', remote: true %>
10
+
11
+ <%= link_back save_path, method: :put %>
12
+
13
+ <%= link_back 'All options!', save_path, id: 'all-options' %>
14
+
15
+ <%= link_back 'http://localhost:3000/tests/clear_and_save', save_path %>
16
+
17
+ <%= link_back 'Offsite okay!', offsite: true %>
@@ -0,0 +1,10 @@
1
+ Save Path
2
+ <%= form_tag redirect_with_options_path do %>
3
+ <%= submit_tag 'Post to redirect_with_options' %>
4
+ <% end %>
5
+
6
+ <%= link_to 'Go to edit page', clear_and_save_path %>
7
+
8
+ <%= link_to 'Go to blank page', blank_path %>
9
+
10
+ <%= link_back %>
@@ -1,61 +1,13 @@
1
1
  Rails.application.routes.draw do
2
- get 'tests/offsite_with_default' => 'tests#offsite_with_default', as: 'offsite_with_default'
3
- get 'tests/offsite_without_default' => 'tests#offsite_without_default', as: 'offsite_without_default'
4
- resources :tests
5
-
6
- root 'tests#index'
7
- # The priority is based upon order of creation: first created -> highest priority.
8
- # See how all your routes lay out with "rake routes".
9
-
10
- # You can have the root of your site routed with "root"
11
- # root 'welcome#index'
12
-
13
- # Example of regular route:
14
- # get 'products/:id' => 'catalog#view'
15
-
16
- # Example of named route that can be invoked with purchase_url(id: product.id)
17
- # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
18
-
19
- # Example resource route (maps HTTP verbs to controller actions automatically):
20
- # resources :products
21
-
22
- # Example resource route with options:
23
- # resources :products do
24
- # member do
25
- # get 'short'
26
- # post 'toggle'
27
- # end
28
- #
29
- # collection do
30
- # get 'sold'
31
- # end
32
- # end
33
-
34
- # Example resource route with sub-resources:
35
- # resources :products do
36
- # resources :comments, :sales
37
- # resource :seller
38
- # end
39
-
40
- # Example resource route with more complex sub-resources:
41
- # resources :products do
42
- # resources :comments
43
- # resources :sales do
44
- # get 'recent', on: :collection
45
- # end
46
- # end
47
-
48
- # Example resource route with concerns:
49
- # concern :toggleable do
50
- # post 'toggle'
51
- # end
52
- # resources :posts, concerns: :toggleable
53
- # resources :photos, concerns: :toggleable
54
-
55
- # Example resource route within a namespace:
56
- # namespace :admin do
57
- # # Directs /admin/products/* to Admin::ProductsController
58
- # # (app/controllers/admin/products_controller.rb)
59
- # resources :products
60
- # end
2
+ get 'tests/offsite_with_path' => 'tests#offsite_with_path', as: 'offsite_with_path'
3
+ get 'tests/offsite' => 'tests#offsite', as: 'offsite'
4
+ get 'tests/blank' => 'tests#blank', as: 'blank'
5
+ get 'tests/return_with_path' => 'tests#return_with_path', as: 'return_with_path'
6
+ get 'tests/save' => 'tests#save', as: 'save'
7
+ post 'tests/redirect_with_options' => 'tests#redirect_with_options', as: 'redirect_with_options'
8
+ get 'tests/clear_and_save' => 'tests#clear_and_save', as: 'clear_and_save'
9
+ put 'tests/return_with_options' => 'tests#return_with_options', as: 'return_with_options'
10
+ delete 'tests/clear_and_redirect' => 'tests#clear_and_redirect', as: 'clear_and_redirect'
11
+
12
+ root 'tests#blank'
61
13
  end
Binary file