unobtrusive_flash 3.2.0 → 3.3.0

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: bcf0d645c08a7ad2d63f5955edace9e8a4578be0
4
- data.tar.gz: fdeae4c247e4ca3705983042b7697d77b4220406
3
+ metadata.gz: a02bf176fb80148daba59bb10f1e79b2a4e72b34
4
+ data.tar.gz: 10b52ffc976f2a11dad96c8af566cbcc53348b02
5
5
  SHA512:
6
- metadata.gz: b73cbd1239dcde8e44719d92f0e265ff70da474a6eb4e523ce399a6f49f2fd6cfbd5209b073929ed9d4de69e6c4e23f3f8fdfedce6ad545640e206650f5a1a50
7
- data.tar.gz: acc75fb3ca59e8973ab6a318f438861112a8a864755c4700a9e44d8799e1cbaf9780f546fd6d62ac090a2761f7de896b5fe8f252c6ed5e787256f14747255d2e
6
+ metadata.gz: daa0219436c7fdb69fdc6ac00c5ba7841f9aa3fb9e87fa1733be4748a2d4a134aa975cfae75ce7dfdc2781ba96cbc3b3cdaf4f68608a6d04d150a7839694fcaf
7
+ data.tar.gz: 9e84204b39d959d05f19d483f85fcc2c986fca340ec7573a2ba6f3f42925e78ddde89f31b4aae67995d5bc8a22e2971b0f062d0e503cc6ee45a7046a99c6ad8b
data/.travis.yml CHANGED
@@ -1,17 +1,33 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9
5
- - 2.0
6
- - 2.2
4
+ - jruby-9.1.2.0
5
+ - 1.9.3
6
+ - 2.0.0-p648
7
+ - 2.2.5
8
+ - 2.3.1
7
9
  gemfile:
8
10
  - gemfiles/rails_3.2.gemfile
9
11
  - gemfiles/rails_4.0.gemfile
10
12
  - gemfiles/rails_4.1.gemfile
11
13
  - gemfiles/rails_4.2.gemfile
14
+ - gemfiles/rails_5.gemfile
12
15
  env:
13
16
  matrix:
14
- - JQUERY_VERSION=2.1.1
15
- - JQUERY_VERSION=1.11.1
17
+ - JQUERY_VERSION=1.12.4
18
+ - JQUERY_VERSION=2.2.4
19
+ - JQUERY_VERSION=3.1.0
20
+ matrix:
21
+ exclude:
22
+ - rvm: 1.9.3
23
+ gemfile: gemfiles/rails_5.gemfile
24
+ - rvm: 2.0.0-p648
25
+ gemfile: gemfiles/rails_5.gemfile
16
26
 
17
- script: bundle exec rake spec
27
+ script: bundle exec rspec spec
28
+
29
+ before_install:
30
+ - mkdir travis-phantomjs
31
+ - wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
32
+ - tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs
33
+ - export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH
data/Appraisals CHANGED
@@ -23,3 +23,10 @@ appraise "rails-4.2" do
23
23
  gem 'turbolinks'
24
24
  gem 'jquery-turbolinks', '>2'
25
25
  end
26
+
27
+ appraise "rails-5" do
28
+ gem "rails", "~>5.0.0"
29
+ gem 'jquery-rails', '~> 4.2.1'
30
+ gem 'turbolinks'
31
+ gem 'jquery-turbolinks', '>2'
32
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 2016-11-08 3.3.0
2
+
3
+ * Now compatible with jQuery 1, 2 and 3.
4
+ * Now compatible with Rails 5.
5
+ * Now compatible with turbolinks 5.
6
+ * Make bootstrap flash mapping configurable [#31]
7
+ * Do not repeat flash messages [#32]
8
+ * Support AWS ELB out of the box [#33]
9
+ * Only show user-facing flash messages [#21]
10
+ * Tested with JRuby
11
+
1
12
  ## 2015-11-06 3.2.0
2
13
 
3
14
  * Support passing flash with non-successful (non-200) AJAX requests thanks to @Markwallow [#28]
data/README.markdown CHANGED
@@ -17,8 +17,8 @@ Tested in all major browsers, including Internet Explorer 8 and later.
17
17
 
18
18
  ## Requirements
19
19
 
20
- * Rails >=3 (Latest versions of 3.2, 4.0, 4.1, 4.2 are automatically tested)
21
- * jQuery (Latest versions of both jQuery 1 and jQuery 2 are automatically tested)
20
+ * Rails >=3 (Latest versions of 3.2, 4.0, 4.1, 4.2, and 5.0 are automatically tested)
21
+ * jQuery (Latest versions of jQuery 1, 2 and 3 are automatically tested)
22
22
 
23
23
  ## Usage
24
24
 
@@ -54,6 +54,11 @@ If you want the flash messages to disappear automatically, set this in your Java
54
54
  UnobtrusiveFlash.flashOptions['timeout'] = 2000; // milliseconds
55
55
  ```
56
56
 
57
+ You can config the resulting mapping classes like this:
58
+ ```javascript
59
+ UnobtrusiveFlash.flashOptions.mapping.notice = 'success'
60
+ ```
61
+
57
62
  ### Option 2: For non-Bootstrap projects
58
63
 
59
64
  Also `require unobtrusive_flash_ui` in your `application.js` and `require unobtrusive_flash_ui` in your `application.css`. These files contain a no-frills flash message UI that works out of the box.
@@ -91,6 +96,18 @@ UnobtrusiveFlash.showFlashMessage('Hello World', {type: 'notice'})
91
96
  UnobtrusiveFlash.showFlashMessage('Error', {type: 'error', timeout: 0})
92
97
  ```
93
98
 
99
+ ## Using flash keys other than `notice, alert, error`
100
+
101
+ By default, Unobtrusive Flash only displays the three "default" Rails flash types: `notice`, `alert`, and `error`. This is because some libraries use `flash` to keep data that is not directed at the user; for example, [Devise](https://github.com/plataformatec/devise) uses a boolean `flash[:timedout]`. If you use other keys to store messages, override `unobtrusive_flash_keys` in your controller:
102
+
103
+ ```ruby
104
+ class ApplicationController
105
+ def unobtrusive_flash_keys
106
+ super << :success
107
+ end
108
+ end
109
+ ```
110
+
94
111
  ## Issue with certain "hosted domains"
95
112
 
96
113
  There are [certain domains](https://publicsuffix.org/list/) that are considered "public" or "hosting" and specifically don't share cookies across subdomains. An example is `herokuapp.com` - a cookie set for `yourapp.herokuapp.com` will not be applied for `myapp.herokuapp.com`. This breaks the logic of `unobtrusive_flash` which is tuned for regular domains that could have internal subdomains.
@@ -117,8 +134,6 @@ appraisal rake spec
117
134
 
118
135
  The same tests are ran on Travis CI against multiple versions of Ruby and jQuery.
119
136
 
120
- The Travis CI build does not test turbolinks as of now, because PhantomJS 1 does not support the necessary APIs. However, if you run the tests outside of Travis, they will use Selenium and perform a full range of tests.
121
-
122
137
  * * *
123
138
 
124
- &copy; 2010-2014 [Leonid Shevtsov](http://leonid.shevtsov.me) and [contributors](https://github.com/leonid-shevtsov/unobtrusive_flash/graphs/contributors), released under the MIT license
139
+ &copy; 2010-2016 [Leonid Shevtsov](http://leonid.shevtsov.me) and [contributors](https://github.com/leonid-shevtsov/unobtrusive_flash/graphs/contributors), released under the MIT license
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'rspec/core/rake_task'
3
- require 'rails' # for Sauce to work
4
3
 
5
4
  RSpec::Core::RakeTask.new(:spec)
6
5
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- unobtrusive_flash (3.1.1)
4
+ unobtrusive_flash (3.2.0)
5
5
  railties
6
6
 
7
7
  GEM
@@ -46,12 +46,9 @@ GEM
46
46
  rack (>= 1.0.0)
47
47
  rack-test (>= 0.5.4)
48
48
  xpath (~> 2.0)
49
- childprocess (0.5.6)
50
- ffi (~> 1.0, >= 1.0.11)
51
49
  cliver (0.3.2)
52
50
  diff-lcs (1.2.5)
53
51
  erubis (2.7.0)
54
- ffi (1.9.10)
55
52
  hike (1.2.3)
56
53
  i18n (0.7.0)
57
54
  journey (1.0.4)
@@ -59,6 +56,7 @@ GEM
59
56
  railties (>= 3.0, < 5.0)
60
57
  thor (>= 0.14, < 2.0)
61
58
  json (1.8.3)
59
+ json (1.8.3-java)
62
60
  mail (2.5.4)
63
61
  mime-types (~> 1.16)
64
62
  treetop (~> 1.4.8)
@@ -67,10 +65,10 @@ GEM
67
65
  multi_json (1.11.2)
68
66
  nokogiri (1.6.6.2)
69
67
  mini_portile (~> 0.6.0)
70
- poltergeist (1.7.0)
68
+ nokogiri (1.6.6.2-java)
69
+ poltergeist (1.10.0)
71
70
  capybara (~> 2.1)
72
71
  cliver (~> 0.3.1)
73
- multi_json (~> 1.0)
74
72
  websocket-driver (>= 0.2.0)
75
73
  polyglot (0.3.5)
76
74
  rack (1.4.7)
@@ -111,12 +109,6 @@ GEM
111
109
  diff-lcs (>= 1.2.0, < 2.0)
112
110
  rspec-support (~> 3.3.0)
113
111
  rspec-support (3.3.0)
114
- rubyzip (1.1.7)
115
- selenium-webdriver (2.48.1)
116
- childprocess (~> 0.5)
117
- multi_json (~> 1.0)
118
- rubyzip (~> 1.0)
119
- websocket (~> 1.0)
120
112
  sprockets (2.2.3)
121
113
  hike (~> 1.2)
122
114
  multi_json (~> 1.0)
@@ -128,14 +120,16 @@ GEM
128
120
  polyglot
129
121
  polyglot (>= 0.3.1)
130
122
  tzinfo (0.3.45)
131
- websocket (1.2.2)
132
- websocket-driver (0.6.2)
123
+ websocket-driver (0.6.4)
124
+ websocket-extensions (>= 0.1.0)
125
+ websocket-driver (0.6.4-java)
133
126
  websocket-extensions (>= 0.1.0)
134
127
  websocket-extensions (0.1.2)
135
128
  xpath (2.0.0)
136
129
  nokogiri (~> 1.3)
137
130
 
138
131
  PLATFORMS
132
+ java
139
133
  ruby
140
134
 
141
135
  DEPENDENCIES
@@ -143,13 +137,12 @@ DEPENDENCIES
143
137
  bundler (~> 1.3)
144
138
  capybara (>= 2.5)
145
139
  jquery-rails (~> 2.1)
146
- poltergeist
140
+ poltergeist (>= 1.10.0)
147
141
  rails (~> 3.2.22)
148
142
  rake
149
143
  rspec (~> 3)
150
144
  rspec-mocks (~> 3)
151
- selenium-webdriver
152
145
  unobtrusive_flash!
153
146
 
154
147
  BUNDLED WITH
155
- 1.10.6
148
+ 1.12.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- unobtrusive_flash (3.1.1)
4
+ unobtrusive_flash (3.2.0)
5
5
  railties
6
6
 
7
7
  GEM
@@ -43,8 +43,6 @@ GEM
43
43
  rack (>= 1.0.0)
44
44
  rack-test (>= 0.5.4)
45
45
  xpath (~> 2.0)
46
- childprocess (0.5.6)
47
- ffi (~> 1.0, >= 1.0.11)
48
46
  cliver (0.3.2)
49
47
  coffee-rails (4.1.0)
50
48
  coffee-script (>= 2.2.0)
@@ -56,7 +54,6 @@ GEM
56
54
  diff-lcs (1.2.5)
57
55
  erubis (2.7.0)
58
56
  execjs (2.6.0)
59
- ffi (1.9.10)
60
57
  i18n (0.7.0)
61
58
  jquery-rails (2.3.0)
62
59
  railties (>= 3.0, < 5.0)
@@ -72,10 +69,10 @@ GEM
72
69
  multi_json (1.11.2)
73
70
  nokogiri (1.6.6.2)
74
71
  mini_portile (~> 0.6.0)
75
- poltergeist (1.7.0)
72
+ nokogiri (1.6.6.2-java)
73
+ poltergeist (1.10.0)
76
74
  capybara (~> 2.1)
77
75
  cliver (~> 0.3.1)
78
- multi_json (~> 1.0)
79
76
  websocket-driver (>= 0.2.0)
80
77
  rack (1.5.5)
81
78
  rack-test (0.6.3)
@@ -107,12 +104,6 @@ GEM
107
104
  diff-lcs (>= 1.2.0, < 2.0)
108
105
  rspec-support (~> 3.3.0)
109
106
  rspec-support (3.3.0)
110
- rubyzip (1.1.7)
111
- selenium-webdriver (2.48.1)
112
- childprocess (~> 0.5)
113
- multi_json (~> 1.0)
114
- rubyzip (~> 1.0)
115
- websocket (~> 1.0)
116
107
  sprockets (3.4.0)
117
108
  rack (> 1, < 3)
118
109
  sprockets-rails (2.3.3)
@@ -121,17 +112,20 @@ GEM
121
112
  sprockets (>= 2.8, < 4.0)
122
113
  thor (0.19.1)
123
114
  thread_safe (0.3.5)
115
+ thread_safe (0.3.5-java)
124
116
  turbolinks (2.5.3)
125
117
  coffee-rails
126
118
  tzinfo (0.3.45)
127
- websocket (1.2.2)
128
- websocket-driver (0.6.2)
119
+ websocket-driver (0.6.4)
120
+ websocket-extensions (>= 0.1.0)
121
+ websocket-driver (0.6.4-java)
129
122
  websocket-extensions (>= 0.1.0)
130
123
  websocket-extensions (0.1.2)
131
124
  xpath (2.0.0)
132
125
  nokogiri (~> 1.3)
133
126
 
134
127
  PLATFORMS
128
+ java
135
129
  ruby
136
130
 
137
131
  DEPENDENCIES
@@ -140,14 +134,13 @@ DEPENDENCIES
140
134
  capybara (>= 2.5)
141
135
  jquery-rails (~> 2.1)
142
136
  jquery-turbolinks (> 2)
143
- poltergeist
137
+ poltergeist (>= 1.10.0)
144
138
  rails (~> 4.0.13)
145
139
  rake
146
140
  rspec (~> 3)
147
141
  rspec-mocks (~> 3)
148
- selenium-webdriver
149
142
  turbolinks
150
143
  unobtrusive_flash!
151
144
 
152
145
  BUNDLED WITH
153
- 1.10.6
146
+ 1.12.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- unobtrusive_flash (3.1.1)
4
+ unobtrusive_flash (3.2.0)
5
5
  railties
6
6
 
7
7
  GEM
@@ -45,8 +45,6 @@ GEM
45
45
  rack (>= 1.0.0)
46
46
  rack-test (>= 0.5.4)
47
47
  xpath (~> 2.0)
48
- childprocess (0.5.6)
49
- ffi (~> 1.0, >= 1.0.11)
50
48
  cliver (0.3.2)
51
49
  coffee-rails (4.1.0)
52
50
  coffee-script (>= 2.2.0)
@@ -58,7 +56,6 @@ GEM
58
56
  diff-lcs (1.2.5)
59
57
  erubis (2.7.0)
60
58
  execjs (2.6.0)
61
- ffi (1.9.10)
62
59
  i18n (0.7.0)
63
60
  jquery-rails (2.3.0)
64
61
  railties (>= 3.0, < 5.0)
@@ -67,18 +64,18 @@ GEM
67
64
  railties (>= 3.1.0)
68
65
  turbolinks
69
66
  json (1.8.3)
67
+ json (1.8.3-java)
70
68
  mail (2.6.3)
71
69
  mime-types (>= 1.16, < 3)
72
70
  mime-types (2.6.2)
73
71
  mini_portile (0.6.2)
74
72
  minitest (5.8.2)
75
- multi_json (1.11.2)
76
73
  nokogiri (1.6.6.2)
77
74
  mini_portile (~> 0.6.0)
78
- poltergeist (1.7.0)
75
+ nokogiri (1.6.6.2-java)
76
+ poltergeist (1.10.0)
79
77
  capybara (~> 2.1)
80
78
  cliver (~> 0.3.1)
81
- multi_json (~> 1.0)
82
79
  websocket-driver (>= 0.2.0)
83
80
  rack (1.5.5)
84
81
  rack-test (0.6.3)
@@ -112,12 +109,6 @@ GEM
112
109
  diff-lcs (>= 1.2.0, < 2.0)
113
110
  rspec-support (~> 3.3.0)
114
111
  rspec-support (3.3.0)
115
- rubyzip (1.1.7)
116
- selenium-webdriver (2.48.1)
117
- childprocess (~> 0.5)
118
- multi_json (~> 1.0)
119
- rubyzip (~> 1.0)
120
- websocket (~> 1.0)
121
112
  sprockets (3.4.0)
122
113
  rack (> 1, < 3)
123
114
  sprockets-rails (2.3.3)
@@ -126,18 +117,21 @@ GEM
126
117
  sprockets (>= 2.8, < 4.0)
127
118
  thor (0.19.1)
128
119
  thread_safe (0.3.5)
120
+ thread_safe (0.3.5-java)
129
121
  turbolinks (2.5.3)
130
122
  coffee-rails
131
123
  tzinfo (1.2.2)
132
124
  thread_safe (~> 0.1)
133
- websocket (1.2.2)
134
- websocket-driver (0.6.2)
125
+ websocket-driver (0.6.4)
126
+ websocket-extensions (>= 0.1.0)
127
+ websocket-driver (0.6.4-java)
135
128
  websocket-extensions (>= 0.1.0)
136
129
  websocket-extensions (0.1.2)
137
130
  xpath (2.0.0)
138
131
  nokogiri (~> 1.3)
139
132
 
140
133
  PLATFORMS
134
+ java
141
135
  ruby
142
136
 
143
137
  DEPENDENCIES
@@ -146,14 +140,13 @@ DEPENDENCIES
146
140
  capybara (>= 2.5)
147
141
  jquery-rails (~> 2.1)
148
142
  jquery-turbolinks (> 2)
149
- poltergeist
143
+ poltergeist (>= 1.10.0)
150
144
  rails (~> 4.1.13)
151
145
  rake
152
146
  rspec (~> 3)
153
147
  rspec-mocks (~> 3)
154
- selenium-webdriver
155
148
  turbolinks
156
149
  unobtrusive_flash!
157
150
 
158
151
  BUNDLED WITH
159
- 1.10.6
152
+ 1.12.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- unobtrusive_flash (3.1.1)
4
+ unobtrusive_flash (3.2.0)
5
5
  railties
6
6
 
7
7
  GEM
@@ -54,8 +54,6 @@ GEM
54
54
  rack (>= 1.0.0)
55
55
  rack-test (>= 0.5.4)
56
56
  xpath (~> 2.0)
57
- childprocess (0.5.6)
58
- ffi (~> 1.0, >= 1.0.11)
59
57
  cliver (0.3.2)
60
58
  coffee-rails (4.1.0)
61
59
  coffee-script (>= 2.2.0)
@@ -67,7 +65,6 @@ GEM
67
65
  diff-lcs (1.2.5)
68
66
  erubis (2.7.0)
69
67
  execjs (2.6.0)
70
- ffi (1.9.10)
71
68
  globalid (0.3.6)
72
69
  activesupport (>= 4.1.0)
73
70
  i18n (0.7.0)
@@ -78,6 +75,7 @@ GEM
78
75
  railties (>= 3.1.0)
79
76
  turbolinks
80
77
  json (1.8.3)
78
+ json (1.8.3-java)
81
79
  loofah (2.0.3)
82
80
  nokogiri (>= 1.5.9)
83
81
  mail (2.6.3)
@@ -85,13 +83,12 @@ GEM
85
83
  mime-types (2.6.2)
86
84
  mini_portile (0.6.2)
87
85
  minitest (5.8.2)
88
- multi_json (1.11.2)
89
86
  nokogiri (1.6.6.2)
90
87
  mini_portile (~> 0.6.0)
91
- poltergeist (1.7.0)
88
+ nokogiri (1.6.6.2-java)
89
+ poltergeist (1.10.0)
92
90
  capybara (~> 2.1)
93
91
  cliver (~> 0.3.1)
94
- multi_json (~> 1.0)
95
92
  websocket-driver (>= 0.2.0)
96
93
  rack (1.6.4)
97
94
  rack-test (0.6.3)
@@ -134,12 +131,6 @@ GEM
134
131
  diff-lcs (>= 1.2.0, < 2.0)
135
132
  rspec-support (~> 3.3.0)
136
133
  rspec-support (3.3.0)
137
- rubyzip (1.1.7)
138
- selenium-webdriver (2.48.1)
139
- childprocess (~> 0.5)
140
- multi_json (~> 1.0)
141
- rubyzip (~> 1.0)
142
- websocket (~> 1.0)
143
134
  sprockets (3.4.0)
144
135
  rack (> 1, < 3)
145
136
  sprockets-rails (2.3.3)
@@ -148,18 +139,21 @@ GEM
148
139
  sprockets (>= 2.8, < 4.0)
149
140
  thor (0.19.1)
150
141
  thread_safe (0.3.5)
142
+ thread_safe (0.3.5-java)
151
143
  turbolinks (2.5.3)
152
144
  coffee-rails
153
145
  tzinfo (1.2.2)
154
146
  thread_safe (~> 0.1)
155
- websocket (1.2.2)
156
- websocket-driver (0.6.2)
147
+ websocket-driver (0.6.4)
148
+ websocket-extensions (>= 0.1.0)
149
+ websocket-driver (0.6.4-java)
157
150
  websocket-extensions (>= 0.1.0)
158
151
  websocket-extensions (0.1.2)
159
152
  xpath (2.0.0)
160
153
  nokogiri (~> 1.3)
161
154
 
162
155
  PLATFORMS
156
+ java
163
157
  ruby
164
158
 
165
159
  DEPENDENCIES
@@ -168,14 +162,13 @@ DEPENDENCIES
168
162
  capybara (>= 2.5)
169
163
  jquery-rails (~> 2.1)
170
164
  jquery-turbolinks (> 2)
171
- poltergeist
165
+ poltergeist (>= 1.10.0)
172
166
  rails (~> 4.2.4)
173
167
  rake
174
168
  rspec (~> 3)
175
169
  rspec-mocks (~> 3)
176
- selenium-webdriver
177
170
  turbolinks
178
171
  unobtrusive_flash!
179
172
 
180
173
  BUNDLED WITH
181
- 1.10.6
174
+ 1.12.5
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~>5.0.0"
6
+ gem "jquery-rails", "~> 4.2.1"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,171 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ unobtrusive_flash (3.2.0)
5
+ railties
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.0.0.1)
11
+ actionpack (= 5.0.0.1)
12
+ nio4r (~> 1.2)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.0.0.1)
15
+ actionpack (= 5.0.0.1)
16
+ actionview (= 5.0.0.1)
17
+ activejob (= 5.0.0.1)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.0.0.1)
21
+ actionview (= 5.0.0.1)
22
+ activesupport (= 5.0.0.1)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.0.0.1)
28
+ activesupport (= 5.0.0.1)
29
+ builder (~> 3.1)
30
+ erubis (~> 2.7.0)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
+ activejob (5.0.0.1)
34
+ activesupport (= 5.0.0.1)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.0.0.1)
37
+ activesupport (= 5.0.0.1)
38
+ activerecord (5.0.0.1)
39
+ activemodel (= 5.0.0.1)
40
+ activesupport (= 5.0.0.1)
41
+ arel (~> 7.0)
42
+ activesupport (5.0.0.1)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
47
+ addressable (2.4.0)
48
+ appraisal (2.1.0)
49
+ bundler
50
+ rake
51
+ thor (>= 0.14.0)
52
+ arel (7.1.1)
53
+ builder (3.2.2)
54
+ capybara (2.8.1)
55
+ addressable
56
+ mime-types (>= 1.16)
57
+ nokogiri (>= 1.3.3)
58
+ rack (>= 1.0.0)
59
+ rack-test (>= 0.5.4)
60
+ xpath (~> 2.0)
61
+ cliver (0.3.2)
62
+ concurrent-ruby (1.0.2)
63
+ concurrent-ruby (1.0.2-java)
64
+ diff-lcs (1.2.5)
65
+ erubis (2.7.0)
66
+ globalid (0.3.7)
67
+ activesupport (>= 4.1.0)
68
+ i18n (0.7.0)
69
+ jquery-rails (4.2.1)
70
+ rails-dom-testing (>= 1, < 3)
71
+ railties (>= 4.2.0)
72
+ thor (>= 0.14, < 2.0)
73
+ loofah (2.0.3)
74
+ nokogiri (>= 1.5.9)
75
+ mail (2.6.4)
76
+ mime-types (>= 1.16, < 4)
77
+ method_source (0.8.2)
78
+ mime-types (3.1)
79
+ mime-types-data (~> 3.2015)
80
+ mime-types-data (3.2016.0521)
81
+ mini_portile2 (2.1.0)
82
+ minitest (5.9.0)
83
+ nio4r (1.2.1)
84
+ nio4r (1.2.1-java)
85
+ nokogiri (1.6.8)
86
+ mini_portile2 (~> 2.1.0)
87
+ pkg-config (~> 1.1.7)
88
+ nokogiri (1.6.8-java)
89
+ pkg-config (1.1.7)
90
+ poltergeist (1.10.0)
91
+ capybara (~> 2.1)
92
+ cliver (~> 0.3.1)
93
+ websocket-driver (>= 0.2.0)
94
+ rack (2.0.1)
95
+ rack-test (0.6.3)
96
+ rack (>= 1.0)
97
+ rails (5.0.0.1)
98
+ actioncable (= 5.0.0.1)
99
+ actionmailer (= 5.0.0.1)
100
+ actionpack (= 5.0.0.1)
101
+ actionview (= 5.0.0.1)
102
+ activejob (= 5.0.0.1)
103
+ activemodel (= 5.0.0.1)
104
+ activerecord (= 5.0.0.1)
105
+ activesupport (= 5.0.0.1)
106
+ bundler (>= 1.3.0, < 2.0)
107
+ railties (= 5.0.0.1)
108
+ sprockets-rails (>= 2.0.0)
109
+ rails-dom-testing (2.0.1)
110
+ activesupport (>= 4.2.0, < 6.0)
111
+ nokogiri (~> 1.6.0)
112
+ rails-html-sanitizer (1.0.3)
113
+ loofah (~> 2.0)
114
+ railties (5.0.0.1)
115
+ actionpack (= 5.0.0.1)
116
+ activesupport (= 5.0.0.1)
117
+ method_source
118
+ rake (>= 0.8.7)
119
+ thor (>= 0.18.1, < 2.0)
120
+ rake (11.2.2)
121
+ rspec (3.5.0)
122
+ rspec-core (~> 3.5.0)
123
+ rspec-expectations (~> 3.5.0)
124
+ rspec-mocks (~> 3.5.0)
125
+ rspec-core (3.5.2)
126
+ rspec-support (~> 3.5.0)
127
+ rspec-expectations (3.5.0)
128
+ diff-lcs (>= 1.2.0, < 2.0)
129
+ rspec-support (~> 3.5.0)
130
+ rspec-mocks (3.5.0)
131
+ diff-lcs (>= 1.2.0, < 2.0)
132
+ rspec-support (~> 3.5.0)
133
+ rspec-support (3.5.0)
134
+ sprockets (3.7.0)
135
+ concurrent-ruby (~> 1.0)
136
+ rack (> 1, < 3)
137
+ sprockets-rails (3.1.1)
138
+ actionpack (>= 4.0)
139
+ activesupport (>= 4.0)
140
+ sprockets (>= 3.0.0)
141
+ thor (0.19.1)
142
+ thread_safe (0.3.5)
143
+ thread_safe (0.3.5-java)
144
+ tzinfo (1.2.2)
145
+ thread_safe (~> 0.1)
146
+ websocket-driver (0.6.4)
147
+ websocket-extensions (>= 0.1.0)
148
+ websocket-driver (0.6.4-java)
149
+ websocket-extensions (>= 0.1.0)
150
+ websocket-extensions (0.1.2)
151
+ xpath (2.0.0)
152
+ nokogiri (~> 1.3)
153
+
154
+ PLATFORMS
155
+ java
156
+ ruby
157
+
158
+ DEPENDENCIES
159
+ appraisal
160
+ bundler (~> 1.3)
161
+ capybara (>= 2.5)
162
+ jquery-rails (~> 4.2.1)
163
+ poltergeist (>= 1.10.0)
164
+ rails (~> 5.0.0)
165
+ rake
166
+ rspec (~> 3)
167
+ rspec-mocks (~> 3)
168
+ unobtrusive_flash!
169
+
170
+ BUNDLED WITH
171
+ 1.12.5
@@ -59,12 +59,12 @@ window.UnobtrusiveFlash = {};
59
59
  // We want to remove cookies from the flash as soon as possible, but we only want to show then after all the scripts have loaded,
60
60
  // including any flash handlers
61
61
  var pageCookies = extractFlashFromCookies();
62
- $(window).load(function() {
62
+ $(window).on('load', function() {
63
63
  UnobtrusiveFlash.showFlash(pageCookies);
64
64
  });
65
65
 
66
- $(document).on('page:change page:load', UnobtrusiveFlash.showFlashFromCookies);
67
-
66
+ $(document).on('page:change page:load', UnobtrusiveFlash.showFlashFromCookies); //TURBOLINK-CLASSIC
67
+ $(document).on('turbolinks:load', UnobtrusiveFlash.showFlashFromCookies); //TURBOLINK (5)
68
68
  $(document).ajaxComplete(function(event,request,options) {
69
69
  UnobtrusiveFlash.showFlashFromCookies();
70
70
  });
@@ -4,7 +4,15 @@
4
4
  // Declare a .unobtrusive-flash-container wherever you want the messages to appear
5
5
  // Defaults to .container, .container-fluid (core Bootstrap classes), or just the body tag, whichever is present
6
6
 
7
- window.UnobtrusiveFlash.flashOptions = {type: 'notice', timeout: 0};
7
+ window.UnobtrusiveFlash.flashOptions = {
8
+ type: 'notice',
9
+ timeout: 0,
10
+ mapping: {
11
+ notice: 'info',
12
+ alert: 'warning',
13
+ error: 'danger'
14
+ }
15
+ };
8
16
 
9
17
  (function() {
10
18
 
@@ -12,12 +20,11 @@ window.UnobtrusiveFlash.flashOptions = {type: 'notice', timeout: 0};
12
20
  options = $.extend(UnobtrusiveFlash.flashOptions, options);
13
21
 
14
22
  // Workaround for common Rails flash type to match common Bootstrap alert type
15
- if (options.type=='notice') {
16
- options.type = 'info';
17
- } else if(options.type=='alert') {
18
- options.type = 'warning';
19
- } else if(options.type=='error') {
20
- options.type = 'danger';
23
+ switch (options.type) {
24
+ case 'notice':
25
+ case 'alert':
26
+ case 'error':
27
+ options.type = options.mapping[options.type]
21
28
  }
22
29
 
23
30
  var $flash = $('<div class="alert alert-'+options.type+' fade in"><button type="button" class="close" data-dismiss="alert">&times;</button>'+message+'</div>');
@@ -5,37 +5,61 @@ module UnobtrusiveFlash
5
5
  protected
6
6
 
7
7
  def prepare_unobtrusive_flash
8
- if flash.any?
9
- cookie_flash = []
10
- if cookies['flash']
11
- cookie_flash = JSON.parse(cookies['flash']) rescue nil
12
- cookie_flash=[] unless cookie_flash.is_a? Array
13
- end
14
-
15
- cookie_flash += UnobtrusiveFlash::ControllerMixin.sanitize_flash(flash)
16
- cookies[:flash] = {:value => cookie_flash.to_json, :domain => unobtrusive_flash_domain}
17
- flash.discard
18
- end
8
+ return unless flash.any?
9
+ # TODO: replace configuration based on overriding methods with a conventional config block
10
+ cookies[:flash] = {
11
+ value: UnobtrusiveFlash::ControllerMixin.append_flash_to_cookie(cookies[:flash], flash, unobtrusive_flash_keys),
12
+ domain: unobtrusive_flash_domain
13
+ }
14
+ flash.discard
19
15
  end
20
16
 
21
17
  # Setting cookies for :all domains is broken for Heroku apps, read this article for details
22
18
  # https://devcenter.heroku.com/articles/cookies-and-herokuapp-com
19
+ #
20
+ # Setting cookies for :all domains also appears to be broken for apps hosted on EC2 behind
21
+ # AWS ELB. No written documentation on that yet, only quantitive analysis based on
22
+ # obvservation of a few instances of load balancers and EC2 instances accessed directly
23
+ # via their IP addresses.
24
+ #
23
25
  # You can also override this method in your controller if you need to customize the cookie domain
24
26
  def unobtrusive_flash_domain
25
- if request.host =~ /\.herokuapp\.com$/
27
+ if request.host =~ /\.herokuapp\.com$/ || request.host =~ /\.amazonaws\.com$/
26
28
  request.host
27
29
  else
28
30
  :all
29
31
  end
30
32
  end
31
33
 
34
+ # List of all flash keys that will be displayed on the frontend. Override
35
+ # this method if you use more flash types.
36
+ def unobtrusive_flash_keys
37
+ [:notice, :alert, :error]
38
+ end
39
+
32
40
  class << self
33
- def sanitize_flash(flash)
34
- flash.to_a.map do |key, value|
41
+ # Prepares a safe and clean version of the flash hash for the frontend
42
+ # flash - value of `flash` controller attribute
43
+ # displayable_flash_keys - list of flash keys that will be displayed
44
+ def sanitize_flash(flash, displayable_flash_keys)
45
+ displayable_flash = flash.select { |key, value| displayable_flash_keys.include?(key.to_sym) }
46
+ displayable_flash.map do |key, value|
35
47
  html_safe_value = value.html_safe? ? value : ERB::Util.html_escape(value)
36
- [key, html_safe_value]
48
+ [key.to_s, html_safe_value]
37
49
  end
38
50
  end
51
+
52
+ def append_flash_to_cookie(existing_cookie, flash, unobtrusive_flash_keys)
53
+ if existing_cookie
54
+ cookie_flash = JSON.parse(existing_cookie) rescue []
55
+ else
56
+ cookie_flash = []
57
+ end
58
+
59
+ cookie_flash += sanitize_flash(flash, unobtrusive_flash_keys)
60
+
61
+ cookie_flash.uniq.to_json
62
+ end
39
63
  end
40
64
  end
41
65
  end
@@ -1,3 +1,3 @@
1
1
  module UnobtrusiveFlash
2
- VERSION = "3.2.0"
2
+ VERSION = "3.3.0"
3
3
  end
data/spec/domain_spec.rb CHANGED
@@ -21,5 +21,13 @@ describe UnobtrusiveFlash::ControllerMixin do
21
21
  expect(subject.send(:unobtrusive_flash_domain)).to eq('myapp.herokuapp.com')
22
22
  end
23
23
  end
24
+
25
+ context 'on AWS ELB' do
26
+ let(:host) { 'myapp-1989.eu-west-1.elb.amazonaws.com' }
27
+
28
+ it 'should use the host' do
29
+ expect(subject.send(:unobtrusive_flash_domain)).to eq('myapp-1989.eu-west-1.elb.amazonaws.com')
30
+ end
31
+ end
24
32
  end
25
- end
33
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- if Rails.version =~ /^4\./ and Capybara.javascript_driver == :selenium
3
+ if Rails.version.start_with? "4."
4
4
  describe "turbolinks spec", type: :feature, js: true do
5
5
  it 'should invoke the API for each flash message' do
6
6
  visit '/test/turbolinks'
@@ -3,11 +3,29 @@ require 'spec_helper'
3
3
  describe UnobtrusiveFlash::ControllerMixin do
4
4
  describe '.sanitize_flash' do
5
5
  it 'should escape messages that are not html safe' do
6
- expect(described_class.sanitize_flash({:foo => '<bar>'})).to eq([[:foo, '&lt;bar&gt;']])
6
+ expect(described_class.sanitize_flash({:notice => '<bar>'}, [:notice])).to eq([["notice", '&lt;bar&gt;']])
7
7
  end
8
8
 
9
9
  it 'should not escape messages that are html safe' do
10
- expect(described_class.sanitize_flash({:foo => '<bar>'.html_safe})).to eq([[:foo, '<bar>']])
10
+ expect(described_class.sanitize_flash({:notice => '<bar>'.html_safe}, [:notice])).to eq([["notice", '<bar>']])
11
+ end
12
+
13
+ it 'should remove messages that are not whitelisted to be displayed' do
14
+ expect(described_class.sanitize_flash({:timedout => true}, [:notice])).to eq([])
15
+ end
16
+ end
17
+
18
+ describe '.append_flash_to_cookie' do
19
+ it 'should create a cookie if there is none' do
20
+ expect(described_class.append_flash_to_cookie(nil, {:baz => 'qux'}, [:baz])).to eq('[["baz","qux"]]')
21
+ end
22
+
23
+ it 'should reuse existing cookie' do
24
+ expect(described_class.append_flash_to_cookie('[["foo","bar"]]', {:baz => 'qux'}, [:baz])).to eq('[["foo","bar"],["baz","qux"]]')
25
+ end
26
+
27
+ it 'should not insert flash is already in the cookie' do
28
+ expect(described_class.append_flash_to_cookie('[["foo","bar"]]', {:foo => 'bar'}, [:foo])).to eq('[["foo","bar"]]')
11
29
  end
12
30
  end
13
- end
31
+ end
data/spec/spec_helper.rb CHANGED
@@ -10,11 +10,5 @@ require 'support/rails_app'
10
10
 
11
11
  Capybara.app = TestApp
12
12
 
13
- if ENV['TRAVIS']
14
- # Selenium not available on TraviS CI without many pains.
15
- require 'capybara/poltergeist'
16
- Capybara.javascript_driver = :poltergeist
17
- else
18
- # But Selenium supports turbolinks and PhantomJS does not
19
- Capybara.javascript_driver = :selenium
20
- end
13
+ require 'capybara/poltergeist'
14
+ Capybara.javascript_driver = :poltergeist
@@ -1,4 +1,5 @@
1
1
  $(function() {
2
- $.get('/test/ajax_flash');
3
- $('<span>Page loaded</span>').appendTo('body');
2
+ $.get('/test/ajax_flash', function() {
3
+ $('<span>Page loaded</span>').appendTo('body');
4
+ });
4
5
  });
@@ -4,7 +4,7 @@ require 'rails'
4
4
  require 'action_controller/railtie'
5
5
  require 'sprockets/railtie'
6
6
  require 'jquery-rails'
7
- if Rails.version =~ /^4\./
7
+ if Rails::VERSION::MAJOR == 4
8
8
  require 'turbolinks'
9
9
  require 'jquery-turbolinks'
10
10
  end
@@ -26,18 +26,32 @@ class TestApp < Rails::Application
26
26
  config.assets.paths = [ File.expand_path(__FILE__ + '/../assets/javascripts') ]
27
27
  config.assets.enabled = true
28
28
  config.assets.compile = true
29
+ config.assets.precompile += %w(ui.js bootstrap.js api.js)
29
30
 
30
- config.middleware.delete "Rack::Lock"
31
- config.middleware.delete "ActionDispatch::BestStandardsSupport"
31
+ config.middleware.delete Rack::Lock
32
+
33
+ if Rails::VERSION::MAJOR < 4
34
+ config.middleware.delete ActionDispatch::BestStandardsSupport
35
+ end
32
36
 
33
- # We need a secret token for session, cookies, etc.
34
37
  config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
38
+ config.secret_key_base = "1234567890"
35
39
  end
36
40
 
37
41
  class TestController < ActionController::Base
38
42
  layout false
39
- before_filter :set_inline_flash, except: %w(ajax_flash turbolinks_target)
40
- after_filter :prepare_unobtrusive_flash
43
+
44
+ if Rails::VERSION::MAJOR >= 4
45
+ before_action :set_inline_flash, except: %w(ajax_flash turbolinks_target)
46
+ after_action :prepare_unobtrusive_flash
47
+ else
48
+ before_filter :set_inline_flash, except: %w(ajax_flash turbolinks_target)
49
+ after_filter :prepare_unobtrusive_flash
50
+ end
51
+
52
+ def ui
53
+ flash[:timedout] = 'timedout flash'
54
+ end
41
55
 
42
56
  def turbolinks_target
43
57
  flash[:notice] = 'Turbolink Notice'
@@ -29,8 +29,5 @@ EOT
29
29
  spec.add_development_dependency "rspec-mocks", '~>3'
30
30
  spec.add_development_dependency "appraisal"
31
31
  spec.add_development_dependency "capybara", '>=2.5'
32
- # for local tests
33
- spec.add_development_dependency 'selenium-webdriver'
34
- # for Travis CI
35
- spec.add_development_dependency 'poltergeist'
32
+ spec.add_development_dependency 'poltergeist', '>=1.10.0'
36
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unobtrusive_flash
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Shevtsov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -108,34 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.5'
111
- - !ruby/object:Gem::Dependency
112
- name: selenium-webdriver
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: poltergeist
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
130
116
  - !ruby/object:Gem::Version
131
- version: '0'
117
+ version: 1.10.0
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - ">="
137
123
  - !ruby/object:Gem::Version
138
- version: '0'
124
+ version: 1.10.0
139
125
  description: |
140
126
  unobtrusive_flash takes your flash messages for the backend and automagically passes them to the frontend via HTTP cookies.
141
127
  This works with both regular page loads and AJAX requests, does not tamper with the page body and requires about 3 extra
@@ -161,6 +147,8 @@ files:
161
147
  - gemfiles/rails_4.1.gemfile.lock
162
148
  - gemfiles/rails_4.2.gemfile
163
149
  - gemfiles/rails_4.2.gemfile.lock
150
+ - gemfiles/rails_5.gemfile
151
+ - gemfiles/rails_5.gemfile.lock
164
152
  - lib/assets/javascripts/unobtrusive_flash.js
165
153
  - lib/assets/javascripts/unobtrusive_flash_bootstrap.js
166
154
  - lib/assets/javascripts/unobtrusive_flash_ui.js
@@ -209,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
197
  version: '0'
210
198
  requirements: []
211
199
  rubyforge_project:
212
- rubygems_version: 2.4.5
200
+ rubygems_version: 2.5.2
213
201
  signing_key:
214
202
  specification_version: 4
215
203
  summary: Unobtrusive flash messages for Rails