persistent_params 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.ruby-version +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +95 -0
- data/LICENSE.txt +20 -0
- data/README.md +74 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/persistent_params.rb +84 -0
- data/persistent_params.gemspec +62 -0
- data/test/persistent_params_test.rb +76 -0
- data/test/persistent_scopes_test.rb +44 -0
- data/test/test_helper.rb +35 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7de7241a8c44ae180ef25cd9e27932de5f8ef90c
|
4
|
+
data.tar.gz: 245612b25916d768e8f4b2a03b14c3d83b3dfa5b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8b8e7c7a50995bae22779d1faacbc3d1f60b03efa1c39ada92c337d81fd72a92687bc25755581342116c4d40ccabd5dd043fdcf7b54d4eeb8ae2d2acaabd09e9
|
7
|
+
data.tar.gz: ae37d4bb7719c602350d54973d774346f78b2fb8bcff01e9d1db371fd38ca44ecf5e32bbd8f933dd1ce897968ed16beac90ebc1606075a871ffd61dee16a5cae
|
data/.document
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.3
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (4.2.5)
|
5
|
+
actionview (= 4.2.5)
|
6
|
+
activesupport (= 4.2.5)
|
7
|
+
rack (~> 1.6)
|
8
|
+
rack-test (~> 0.6.2)
|
9
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
10
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
11
|
+
actionview (4.2.5)
|
12
|
+
activesupport (= 4.2.5)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
+
activesupport (4.2.5)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
addressable (2.4.0)
|
24
|
+
builder (3.2.2)
|
25
|
+
descendants_tracker (0.0.4)
|
26
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
27
|
+
erubis (2.7.0)
|
28
|
+
faraday (0.9.2)
|
29
|
+
multipart-post (>= 1.2, < 3)
|
30
|
+
git (1.2.9.1)
|
31
|
+
github_api (0.13.1)
|
32
|
+
addressable (~> 2.4.0)
|
33
|
+
descendants_tracker (~> 0.0.4)
|
34
|
+
faraday (~> 0.8, < 0.10)
|
35
|
+
hashie (>= 3.4)
|
36
|
+
multi_json (>= 1.7.5, < 2.0)
|
37
|
+
oauth2
|
38
|
+
hashie (3.4.3)
|
39
|
+
highline (1.7.8)
|
40
|
+
i18n (0.7.0)
|
41
|
+
jeweler (2.0.1)
|
42
|
+
builder
|
43
|
+
bundler (>= 1.0)
|
44
|
+
git (>= 1.2.5)
|
45
|
+
github_api
|
46
|
+
highline (>= 1.6.15)
|
47
|
+
nokogiri (>= 1.5.10)
|
48
|
+
rake
|
49
|
+
rdoc
|
50
|
+
json (1.8.3)
|
51
|
+
jwt (1.5.2)
|
52
|
+
loofah (2.0.3)
|
53
|
+
nokogiri (>= 1.5.9)
|
54
|
+
mini_portile2 (2.0.0)
|
55
|
+
minitest (5.8.3)
|
56
|
+
multi_json (1.11.2)
|
57
|
+
multi_xml (0.5.5)
|
58
|
+
multipart-post (2.0.0)
|
59
|
+
nokogiri (1.6.7.1)
|
60
|
+
mini_portile2 (~> 2.0.0.rc2)
|
61
|
+
oauth2 (1.0.0)
|
62
|
+
faraday (>= 0.8, < 0.10)
|
63
|
+
jwt (~> 1.0)
|
64
|
+
multi_json (~> 1.3)
|
65
|
+
multi_xml (~> 0.5)
|
66
|
+
rack (~> 1.2)
|
67
|
+
rack (1.6.4)
|
68
|
+
rack-test (0.6.3)
|
69
|
+
rack (>= 1.0)
|
70
|
+
rails-deprecated_sanitizer (1.0.3)
|
71
|
+
activesupport (>= 4.2.0.alpha)
|
72
|
+
rails-dom-testing (1.0.7)
|
73
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
74
|
+
nokogiri (~> 1.6.0)
|
75
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
76
|
+
rails-html-sanitizer (1.0.2)
|
77
|
+
loofah (~> 2.0)
|
78
|
+
rake (10.4.2)
|
79
|
+
rdoc (3.12.2)
|
80
|
+
json (~> 1.4)
|
81
|
+
thread_safe (0.3.5)
|
82
|
+
tzinfo (1.2.2)
|
83
|
+
thread_safe (~> 0.1)
|
84
|
+
|
85
|
+
PLATFORMS
|
86
|
+
ruby
|
87
|
+
|
88
|
+
DEPENDENCIES
|
89
|
+
actionpack (~> 4.2.0)
|
90
|
+
bundler (~> 1.0)
|
91
|
+
jeweler (~> 2.0.1)
|
92
|
+
rdoc (~> 3.12)
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
1.10.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 Diego Aguir Selzlein
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# persistent_params
|
2
|
+
|
3
|
+
Save params in session to use them again when the user goes to another page and
|
4
|
+
comes back. This gem adds a method to Rails controllers called `persists_params`
|
5
|
+
that adds this feature to that controller.
|
6
|
+
|
7
|
+
## What?
|
8
|
+
|
9
|
+
I have to deal with not-so-simple search forms in my `index` templates. It's
|
10
|
+
awful when I combine several filters, search for records, choose one of them
|
11
|
+
to see details and then go back to the `index` page just to see all my filters
|
12
|
+
gone and I have to set them all over.
|
13
|
+
|
14
|
+
With this gem, the controller will save the params in session and, when the
|
15
|
+
same action is invoked again with no params, the request is redirected to the
|
16
|
+
same path, but with the previous used params set.
|
17
|
+
|
18
|
+
It also offers a handy method to integrate with the `HasScope` gem, so `scopes`
|
19
|
+
are persisted between requests.
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
In your Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'persistent_params'
|
27
|
+
```
|
28
|
+
|
29
|
+
In your controller:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
class UsersController < ApplicationController
|
33
|
+
persists_params
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
That's it. All the parameters except `controller` and `action` will be stored
|
38
|
+
and used between requests to the `index` action. If you want to apply to other
|
39
|
+
actions, use the `only` key when calling `persists_params`.
|
40
|
+
|
41
|
+
## HasScope Integration
|
42
|
+
|
43
|
+
In my case, I use the gem to save scopes defined by
|
44
|
+
[HasScope](https://github.com/plataformatec/has_scope). Not all parameters
|
45
|
+
are scopes, so I created a handy method that configures PersistentParams to
|
46
|
+
save only scopes:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
class UsersController < ApplicationController
|
50
|
+
persists_scopes
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
## Clearing Params
|
55
|
+
|
56
|
+
To actually clear the previous params and prevent the redirecting, you need to
|
57
|
+
parameterize a `?clear=true`. I usually do this with a `link_to` in my `index`:
|
58
|
+
|
59
|
+
```erb
|
60
|
+
<%= link_to 'Clear Filters', users_path(clear: true) %>
|
61
|
+
```
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
* Fork
|
66
|
+
* Clone
|
67
|
+
* Create your branch
|
68
|
+
* Make your changes
|
69
|
+
* Push
|
70
|
+
* Create a Pull Request
|
71
|
+
|
72
|
+
## Copyright
|
73
|
+
|
74
|
+
Copyright (c) 2015 Diego Aguir Selzlein. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "persistent_params"
|
18
|
+
gem.homepage = "http://github.com/nerde/persistent_params"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Persist params by controller/action}
|
21
|
+
gem.description = %Q{Persist your params in session so they are used the next time you call the same controller/action. Works with HasScope.}
|
22
|
+
gem.email = "diego.selzlein@unila.edu.br"
|
23
|
+
gem.authors = ["Diego Aguir Selzlein"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['test'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rdoc/task'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ''
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "persistent_params #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module PersistentParams
|
4
|
+
module ClassMethods
|
5
|
+
def persistent_params_config(hash = {})
|
6
|
+
@persistent_params_config ||= OpenStruct.new(hash)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.included(controller)
|
11
|
+
controller.before_filter :check_last_params
|
12
|
+
controller.extend ClassMethods
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def check_last_params
|
18
|
+
return if skip_this_action?
|
19
|
+
return clear_last_params if clear_last_params?
|
20
|
+
return redirect_to_last_params if current_params.empty?
|
21
|
+
self.last_params = current_params
|
22
|
+
end
|
23
|
+
|
24
|
+
def skip_this_action?
|
25
|
+
!actions_to_persist_params.include?(params[:action])
|
26
|
+
end
|
27
|
+
|
28
|
+
def actions_to_persist_params
|
29
|
+
Array(persistent_params_config.only || 'index').map(&:to_s)
|
30
|
+
end
|
31
|
+
|
32
|
+
def clear_last_params?
|
33
|
+
params[:clear].present?
|
34
|
+
end
|
35
|
+
|
36
|
+
def clear_last_params
|
37
|
+
self.last_params = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def redirect_to_last_params
|
41
|
+
return if last_params.empty?
|
42
|
+
redirect_to **last_params.symbolize_keys
|
43
|
+
end
|
44
|
+
|
45
|
+
def current_params
|
46
|
+
send(params_method).except(*ignored_keys)
|
47
|
+
end
|
48
|
+
|
49
|
+
def params_method
|
50
|
+
persistent_params_config.params_method || :params
|
51
|
+
end
|
52
|
+
|
53
|
+
def ignored_keys
|
54
|
+
%w(controller action)
|
55
|
+
end
|
56
|
+
|
57
|
+
def persistent_params_config
|
58
|
+
self.class.persistent_params_config
|
59
|
+
end
|
60
|
+
|
61
|
+
def last_params
|
62
|
+
session[last_params_key] || {}
|
63
|
+
end
|
64
|
+
|
65
|
+
def last_params=(scopes)
|
66
|
+
session[last_params_key] = scopes
|
67
|
+
end
|
68
|
+
|
69
|
+
def last_params_key
|
70
|
+
"#{params[:controller]}__#{params[:action]}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class ActionController::Base
|
75
|
+
def self.persists_params(**options)
|
76
|
+
include PersistentParams
|
77
|
+
persistent_params_config(options)
|
78
|
+
yield persistent_params_config if block_given?
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.persists_scopes(**options, &block)
|
82
|
+
persists_params(params_method: :current_scopes, **options, &block)
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: persistent_params 1.0.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "persistent_params"
|
9
|
+
s.version = "1.0.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Diego Aguir Selzlein"]
|
14
|
+
s.date = "2015-12-29"
|
15
|
+
s.description = "Persist your params in session so they are used the next time you call the same controller/action. Works with HasScope."
|
16
|
+
s.email = "diego.selzlein@unila.edu.br"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".ruby-version",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.md",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"lib/persistent_params.rb",
|
31
|
+
"persistent_params.gemspec",
|
32
|
+
"test/persistent_params_test.rb",
|
33
|
+
"test/persistent_scopes_test.rb",
|
34
|
+
"test/test_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = "http://github.com/nerde/persistent_params"
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.rubygems_version = "2.4.5.1"
|
39
|
+
s.summary = "Persist params by controller/action"
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 4
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<actionpack>, ["~> 4.2.0"])
|
46
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
47
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
48
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<actionpack>, ["~> 4.2.0"])
|
51
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<actionpack>, ["~> 4.2.0"])
|
57
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MyController < ApplicationController
|
4
|
+
persists_params only: %i(index show)
|
5
|
+
|
6
|
+
def index
|
7
|
+
render nothing: true
|
8
|
+
end
|
9
|
+
|
10
|
+
def show
|
11
|
+
render nothing: true
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
render nothing: true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class PersistentParamsTest < ActionController::TestCase
|
20
|
+
tests MyController
|
21
|
+
|
22
|
+
def test_redirects_to_last_used_params
|
23
|
+
get :index, something: 123
|
24
|
+
|
25
|
+
assert_response :ok
|
26
|
+
|
27
|
+
get :index
|
28
|
+
|
29
|
+
assert_response :found
|
30
|
+
assert_redirected_to(controller: :my, action: :index, something: 123)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_does_not_redirect_empty_params
|
34
|
+
get :index
|
35
|
+
|
36
|
+
assert_response :ok
|
37
|
+
|
38
|
+
get :index
|
39
|
+
|
40
|
+
assert_response :ok
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_clears_params
|
44
|
+
get :index, something: 123
|
45
|
+
|
46
|
+
assert_response :ok
|
47
|
+
|
48
|
+
get :index, clear: true
|
49
|
+
|
50
|
+
assert_response :ok
|
51
|
+
|
52
|
+
get :index
|
53
|
+
|
54
|
+
assert_response :ok
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_isolate_actions
|
58
|
+
get :index, something: 123
|
59
|
+
|
60
|
+
assert_response :ok
|
61
|
+
|
62
|
+
get :show
|
63
|
+
|
64
|
+
assert_response :ok
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_only_actions
|
68
|
+
get :create, something: 123
|
69
|
+
|
70
|
+
assert_response :ok
|
71
|
+
|
72
|
+
get :create
|
73
|
+
|
74
|
+
assert_response :ok
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class HasScopesController < ApplicationController
|
4
|
+
persists_scopes
|
5
|
+
|
6
|
+
def index
|
7
|
+
render nothing: true
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def current_scopes
|
13
|
+
fake_scopes
|
14
|
+
end
|
15
|
+
|
16
|
+
def fake_scopes
|
17
|
+
params.select{ |key, _| key == 'a_scope' } || {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class PersistentScopesTest < ActionController::TestCase
|
22
|
+
tests HasScopesController
|
23
|
+
|
24
|
+
def test_saves_scopes
|
25
|
+
get :index, a_scope: 123
|
26
|
+
|
27
|
+
assert_response :ok
|
28
|
+
|
29
|
+
get :index
|
30
|
+
|
31
|
+
assert_response :found
|
32
|
+
assert_redirected_to(controller: :has_scopes, action: :index, a_scope: 123)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_ignores_another_arguments
|
36
|
+
get :index, not_a_scope: 123
|
37
|
+
|
38
|
+
assert_response :ok
|
39
|
+
|
40
|
+
get :index
|
41
|
+
|
42
|
+
assert_response :ok
|
43
|
+
end
|
44
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'minitest/autorun'
|
11
|
+
|
12
|
+
# Configure Rails
|
13
|
+
ENV['RAILS_ENV'] = 'test'
|
14
|
+
|
15
|
+
require 'action_controller'
|
16
|
+
|
17
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
18
|
+
require 'persistent_params'
|
19
|
+
|
20
|
+
PersistentParams::Routes = ActionDispatch::Routing::RouteSet.new
|
21
|
+
PersistentParams::Routes.draw do
|
22
|
+
get '/:controller(/:action(/:id))'
|
23
|
+
end
|
24
|
+
|
25
|
+
class ApplicationController < ActionController::Base
|
26
|
+
include PersistentParams::Routes.url_helpers
|
27
|
+
end
|
28
|
+
|
29
|
+
class ActiveSupport::TestCase
|
30
|
+
self.test_order = :random if respond_to?(:test_order=)
|
31
|
+
|
32
|
+
setup do
|
33
|
+
@routes = PersistentParams::Routes
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: persistent_params
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Diego Aguir Selzlein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: actionpack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.1
|
69
|
+
description: Persist your params in session so they are used the next time you call
|
70
|
+
the same controller/action. Works with HasScope.
|
71
|
+
email: diego.selzlein@unila.edu.br
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.md
|
77
|
+
files:
|
78
|
+
- ".document"
|
79
|
+
- ".ruby-version"
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- VERSION
|
86
|
+
- lib/persistent_params.rb
|
87
|
+
- persistent_params.gemspec
|
88
|
+
- test/persistent_params_test.rb
|
89
|
+
- test/persistent_scopes_test.rb
|
90
|
+
- test/test_helper.rb
|
91
|
+
homepage: http://github.com/nerde/persistent_params
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.5.1
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Persist params by controller/action
|
115
|
+
test_files: []
|