preserve 0.1.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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +148 -0
  4. data/Rakefile +33 -0
  5. data/lib/preserve.rb +36 -0
  6. data/lib/preserve/version.rb +3 -0
  7. data/spec/dummy/README.rdoc +28 -0
  8. data/spec/dummy/Rakefile +6 -0
  9. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  10. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  11. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  12. data/spec/dummy/app/controllers/parameters_controller.rb +18 -0
  13. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  14. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  15. data/spec/dummy/bin/bundle +3 -0
  16. data/spec/dummy/bin/rails +4 -0
  17. data/spec/dummy/bin/rake +4 -0
  18. data/spec/dummy/bin/setup +29 -0
  19. data/spec/dummy/config.ru +4 -0
  20. data/spec/dummy/config/application.rb +32 -0
  21. data/spec/dummy/config/boot.rb +5 -0
  22. data/spec/dummy/config/database.yml +25 -0
  23. data/spec/dummy/config/environment.rb +5 -0
  24. data/spec/dummy/config/environments/development.rb +41 -0
  25. data/spec/dummy/config/environments/production.rb +79 -0
  26. data/spec/dummy/config/environments/test.rb +42 -0
  27. data/spec/dummy/config/initializers/assets.rb +11 -0
  28. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  29. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  30. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  31. data/spec/dummy/config/initializers/inflections.rb +16 -0
  32. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  33. data/spec/dummy/config/initializers/session_store.rb +3 -0
  34. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  35. data/spec/dummy/config/locales/en.yml +23 -0
  36. data/spec/dummy/config/routes.rb +3 -0
  37. data/spec/dummy/config/secrets.yml +22 -0
  38. data/spec/dummy/db/test.sqlite3 +0 -0
  39. data/spec/dummy/log/test.log +2740 -0
  40. data/spec/dummy/public/404.html +67 -0
  41. data/spec/dummy/public/422.html +67 -0
  42. data/spec/dummy/public/500.html +66 -0
  43. data/spec/dummy/public/favicon.ico +0 -0
  44. data/spec/preserve_spec.rb +46 -0
  45. data/spec/spec_helper.rb +15 -0
  46. data/spec/support/request_helpers.rb +5 -0
  47. metadata +171 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Preserve, type: :request do
4
+ it 'persists a parameter value' do
5
+ get parameters_path, per_page: 20
6
+ get parameters_path
7
+
8
+ expect(json[:per_page].to_i).to eq(20)
9
+ end
10
+
11
+ it 'updates a parameter value' do
12
+ get parameters_path, per_page: 20
13
+ get parameters_path, per_page: 10
14
+
15
+ expect(json[:per_page].to_i).to eq(10)
16
+ end
17
+
18
+ it 'handles multiple arguments' do
19
+ get parameters_path, per_page: 20, page: 5
20
+ get parameters_path
21
+
22
+ expect(json[:per_page].to_i).to eq(20)
23
+ expect(json[:page].to_i).to eq(5)
24
+ end
25
+
26
+ it 'handles restrictions' do
27
+ post parameters_path, per_page: 20
28
+ post parameters_path
29
+
30
+ expect(json[:per_page]).to be_nil
31
+ end
32
+
33
+ it 'handles a session key prefix' do
34
+ get parameters_path, order: 'created_at'
35
+
36
+ key = :preserved_parameters_order
37
+ expect(session[key]).to eq('created_at')
38
+ end
39
+
40
+ it 'supports controller inheritance' do
41
+ get parameters_path, locale: 'en'
42
+ get parameters_path
43
+
44
+ expect(json[:locale]).to eq('en')
45
+ end
46
+ end
@@ -0,0 +1,15 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+
5
+ require 'rspec/rails'
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ config.color = true
14
+ config.include RequestHelpers, type: :request
15
+ end
@@ -0,0 +1,5 @@
1
+ module RequestHelpers
2
+ def json
3
+ @json ||= JSON.parse(response.body).with_indifferent_access
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: preserve
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bartosz Pieńkowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Preserve is a Rails plugin which stores selected parameters in a session
56
+ to make them available in subsequent requests.
57
+ email: pienkowb@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - lib/preserve.rb
66
+ - lib/preserve/version.rb
67
+ - spec/dummy/README.rdoc
68
+ - spec/dummy/Rakefile
69
+ - spec/dummy/app/assets/javascripts/application.js
70
+ - spec/dummy/app/assets/stylesheets/application.css
71
+ - spec/dummy/app/controllers/application_controller.rb
72
+ - spec/dummy/app/controllers/parameters_controller.rb
73
+ - spec/dummy/app/helpers/application_helper.rb
74
+ - spec/dummy/app/views/layouts/application.html.erb
75
+ - spec/dummy/bin/bundle
76
+ - spec/dummy/bin/rails
77
+ - spec/dummy/bin/rake
78
+ - spec/dummy/bin/setup
79
+ - spec/dummy/config.ru
80
+ - spec/dummy/config/application.rb
81
+ - spec/dummy/config/boot.rb
82
+ - spec/dummy/config/database.yml
83
+ - spec/dummy/config/environment.rb
84
+ - spec/dummy/config/environments/development.rb
85
+ - spec/dummy/config/environments/production.rb
86
+ - spec/dummy/config/environments/test.rb
87
+ - spec/dummy/config/initializers/assets.rb
88
+ - spec/dummy/config/initializers/backtrace_silencers.rb
89
+ - spec/dummy/config/initializers/cookies_serializer.rb
90
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
91
+ - spec/dummy/config/initializers/inflections.rb
92
+ - spec/dummy/config/initializers/mime_types.rb
93
+ - spec/dummy/config/initializers/session_store.rb
94
+ - spec/dummy/config/initializers/wrap_parameters.rb
95
+ - spec/dummy/config/locales/en.yml
96
+ - spec/dummy/config/routes.rb
97
+ - spec/dummy/config/secrets.yml
98
+ - spec/dummy/db/test.sqlite3
99
+ - spec/dummy/log/test.log
100
+ - spec/dummy/public/404.html
101
+ - spec/dummy/public/422.html
102
+ - spec/dummy/public/500.html
103
+ - spec/dummy/public/favicon.ico
104
+ - spec/preserve_spec.rb
105
+ - spec/spec_helper.rb
106
+ - spec/support/request_helpers.rb
107
+ homepage: https://github.com/pienkowb/preserve
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 1.9.3
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.5.1
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Persist parameter values between requests
131
+ test_files:
132
+ - spec/dummy/app/assets/javascripts/application.js
133
+ - spec/dummy/app/assets/stylesheets/application.css
134
+ - spec/dummy/app/controllers/application_controller.rb
135
+ - spec/dummy/app/controllers/parameters_controller.rb
136
+ - spec/dummy/app/helpers/application_helper.rb
137
+ - spec/dummy/app/views/layouts/application.html.erb
138
+ - spec/dummy/bin/bundle
139
+ - spec/dummy/bin/rails
140
+ - spec/dummy/bin/rake
141
+ - spec/dummy/bin/setup
142
+ - spec/dummy/config/application.rb
143
+ - spec/dummy/config/boot.rb
144
+ - spec/dummy/config/database.yml
145
+ - spec/dummy/config/environment.rb
146
+ - spec/dummy/config/environments/development.rb
147
+ - spec/dummy/config/environments/production.rb
148
+ - spec/dummy/config/environments/test.rb
149
+ - spec/dummy/config/initializers/assets.rb
150
+ - spec/dummy/config/initializers/backtrace_silencers.rb
151
+ - spec/dummy/config/initializers/cookies_serializer.rb
152
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
153
+ - spec/dummy/config/initializers/inflections.rb
154
+ - spec/dummy/config/initializers/mime_types.rb
155
+ - spec/dummy/config/initializers/session_store.rb
156
+ - spec/dummy/config/initializers/wrap_parameters.rb
157
+ - spec/dummy/config/locales/en.yml
158
+ - spec/dummy/config/routes.rb
159
+ - spec/dummy/config/secrets.yml
160
+ - spec/dummy/config.ru
161
+ - spec/dummy/db/test.sqlite3
162
+ - spec/dummy/log/test.log
163
+ - spec/dummy/public/404.html
164
+ - spec/dummy/public/422.html
165
+ - spec/dummy/public/500.html
166
+ - spec/dummy/public/favicon.ico
167
+ - spec/dummy/Rakefile
168
+ - spec/dummy/README.rdoc
169
+ - spec/preserve_spec.rb
170
+ - spec/spec_helper.rb
171
+ - spec/support/request_helpers.rb