cacheable_flash 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -5
  3. data/CHANGELOG +5 -0
  4. data/LICENSE +23 -23
  5. data/README.rdoc +21 -5
  6. data/init.rb +6 -6
  7. data/install.rb +18 -18
  8. data/lib/cacheable_flash.rb +7 -5
  9. data/lib/cacheable_flash/config.rb +3 -1
  10. data/lib/cacheable_flash/engine.rb +10 -7
  11. data/lib/cacheable_flash/middleware.rb +6 -22
  12. data/lib/cacheable_flash/railtie.rb +10 -10
  13. data/lib/cacheable_flash/rspec_matchers.rb +6 -6
  14. data/lib/cacheable_flash/test_helpers.rb +1 -1
  15. data/lib/cacheable_flash/version.rb +3 -3
  16. data/lib/generators/cacheable_flash/install/install_generator.rb +24 -23
  17. data/lib/tasks/cacheable-flash_tasks.rake +4 -4
  18. data/spec/cacheable_flash/cacheable_flash_spec.rb +17 -12
  19. data/spec/cacheable_flash/install_spec.rb +68 -68
  20. data/spec/controllers/controller_test_using_test_unit_spec.rb +28 -0
  21. data/spec/dummy/Rakefile +7 -7
  22. data/spec/dummy/app/assets/javascripts/application.js +15 -15
  23. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  24. data/spec/dummy/app/controllers/application_controller.rb +3 -3
  25. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  26. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  27. data/spec/dummy/config.ru +4 -4
  28. data/spec/dummy/config/application.rb +62 -62
  29. data/spec/dummy/config/boot.rb +9 -9
  30. data/spec/dummy/config/database.yml +25 -25
  31. data/spec/dummy/config/environment.rb +5 -5
  32. data/spec/dummy/config/environments/development.rb +39 -39
  33. data/spec/dummy/config/environments/production.rb +67 -67
  34. data/spec/dummy/config/environments/test.rb +39 -39
  35. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  36. data/spec/dummy/config/initializers/inflections.rb +15 -15
  37. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  38. data/spec/dummy/config/initializers/secret_token.rb +7 -7
  39. data/spec/dummy/config/initializers/session_store.rb +8 -8
  40. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  41. data/spec/dummy/config/locales/en.yml +5 -5
  42. data/spec/dummy/public/404.html +26 -26
  43. data/spec/dummy/public/422.html +26 -26
  44. data/spec/dummy/public/500.html +25 -25
  45. data/spec/dummy/script/rails +6 -6
  46. data/spec/js_unit/cookie_test.html +60 -60
  47. data/spec/js_unit/flash_test.html +112 -112
  48. data/tasks/cacheable_flash_tasks.rake +3 -3
  49. data/vendor/assets/javascripts/{flash.js → flash.js.erb} +2 -2
  50. data/vendor/assets/javascripts/jquery.cookie.js +47 -47
  51. metadata +29 -49
@@ -1,68 +1,68 @@
1
- #This should only be tested for older rails when the generator is used, so commenting out for now.
2
-
3
- #require 'spec_helper'
4
- #
5
- #describe "install.rb" do
6
- # include FileUtils
7
- #
8
- # before do
9
- # @rails_root = "#{Dir.tmpdir}/cachable_flash_#{Time.now.to_f}"
10
- # Object.send(:remove_const, :RAILS_ROOT) if Object.const_defined?(:RAILS_ROOT)
11
- # Object.const_set(:RAILS_ROOT, @rails_root)
12
- #
13
- # @stdout = StringIO.new("")
14
- # $stdout = @stdout
15
- #
16
- # @js_dir = "#{@rails_root}/public/javascripts"
17
- # FileUtils.mkdir_p(@js_dir)
18
- # @install_path = "#{File.dirname(__FILE__)}/../../install.rb"
19
- # end
20
- #
21
- # after do
22
- # $stdout = STDOUT
23
- # end
24
- #
25
- # describe "when project does not have json.js" do
26
- # it "installs javascript files including json.js" do
27
- # File.exists?("#{@js_dir}/flash.js").should be_false
28
- # File.exists?("#{@js_dir}/json.js").should be_false
29
- # File.exists?("#{@js_dir}/cookie.js").should be_false
30
- # load(@install_path)
31
- # File.exists?("#{@js_dir}/flash.js").should be_true
32
- # File.exists?("#{@js_dir}/json.js").should be_true
33
- # File.exists?("#{@js_dir}/cookie.js").should be_true
34
- # end
35
- # end
36
- #
37
- # describe "when project has json.js" do
38
- # it "does not overwrite the existing json.js and installs other javascript files" do
39
- # File.open("#{@js_dir}/json.js", "w") do |f|
40
- # f.write "Original json.js"
41
- # end
42
- # File.exists?("#{@js_dir}/json.js").should be_true
43
- # File.exists?("#{@js_dir}/flash.js").should be_false
44
- # File.exists?("#{@js_dir}/cookie.js").should be_false
45
- # load(@install_path)
46
- # File.exists?("#{@js_dir}/flash.js").should be_true
47
- # File.exists?("#{@js_dir}/cookie.js").should be_true
48
- # File.exists?("#{@js_dir}/json.js").should be_true
49
- # File.read("#{@js_dir}/json.js").should == "Original json.js"
50
- # end
51
- # end
52
- #
53
- # describe "when project has cookie.js" do
54
- # it "does not overwrite the existing cookie.js" do
55
- # File.open("#{@js_dir}/cookie.js", "w") do |f|
56
- # f.write "Original cookie.js"
57
- # end
58
- # File.exists?("#{@js_dir}/json.js").should be_false
59
- # File.exists?("#{@js_dir}/flash.js").should be_false
60
- # File.exists?("#{@js_dir}/cookie.js").should be_true
61
- # load(@install_path)
62
- # File.exists?("#{@js_dir}/flash.js").should be_true
63
- # File.exists?("#{@js_dir}/json.js").should be_true
64
- # File.exists?("#{@js_dir}/cookie.js").should be_true
65
- # File.read("#{@js_dir}/cookie.js").should == "Original cookie.js"
66
- # end
67
- # end
68
- #end
1
+ #This should only be tested for older rails when the generator is used, so commenting out for now.
2
+
3
+ #require 'spec_helper'
4
+ #
5
+ #describe "install.rb" do
6
+ # include FileUtils
7
+ #
8
+ # before do
9
+ # @rails_root = "#{Dir.tmpdir}/cachable_flash_#{Time.now.to_f}"
10
+ # Object.send(:remove_const, :RAILS_ROOT) if Object.const_defined?(:RAILS_ROOT)
11
+ # Object.const_set(:RAILS_ROOT, @rails_root)
12
+ #
13
+ # @stdout = StringIO.new("")
14
+ # $stdout = @stdout
15
+ #
16
+ # @js_dir = "#{@rails_root}/public/javascripts"
17
+ # FileUtils.mkdir_p(@js_dir)
18
+ # @install_path = "#{File.dirname(__FILE__)}/../../install.rb"
19
+ # end
20
+ #
21
+ # after do
22
+ # $stdout = STDOUT
23
+ # end
24
+ #
25
+ # describe "when project does not have json.js" do
26
+ # it "installs javascript files including json.js" do
27
+ # File.exists?("#{@js_dir}/flash.js").should be_false
28
+ # File.exists?("#{@js_dir}/json.js").should be_false
29
+ # File.exists?("#{@js_dir}/cookie.js").should be_false
30
+ # load(@install_path)
31
+ # File.exists?("#{@js_dir}/flash.js").should be_true
32
+ # File.exists?("#{@js_dir}/json.js").should be_true
33
+ # File.exists?("#{@js_dir}/cookie.js").should be_true
34
+ # end
35
+ # end
36
+ #
37
+ # describe "when project has json.js" do
38
+ # it "does not overwrite the existing json.js and installs other javascript files" do
39
+ # File.open("#{@js_dir}/json.js", "w") do |f|
40
+ # f.write "Original json.js"
41
+ # end
42
+ # File.exists?("#{@js_dir}/json.js").should be_true
43
+ # File.exists?("#{@js_dir}/flash.js").should be_false
44
+ # File.exists?("#{@js_dir}/cookie.js").should be_false
45
+ # load(@install_path)
46
+ # File.exists?("#{@js_dir}/flash.js").should be_true
47
+ # File.exists?("#{@js_dir}/cookie.js").should be_true
48
+ # File.exists?("#{@js_dir}/json.js").should be_true
49
+ # File.read("#{@js_dir}/json.js").should == "Original json.js"
50
+ # end
51
+ # end
52
+ #
53
+ # describe "when project has cookie.js" do
54
+ # it "does not overwrite the existing cookie.js" do
55
+ # File.open("#{@js_dir}/cookie.js", "w") do |f|
56
+ # f.write "Original cookie.js"
57
+ # end
58
+ # File.exists?("#{@js_dir}/json.js").should be_false
59
+ # File.exists?("#{@js_dir}/flash.js").should be_false
60
+ # File.exists?("#{@js_dir}/cookie.js").should be_true
61
+ # load(@install_path)
62
+ # File.exists?("#{@js_dir}/flash.js").should be_true
63
+ # File.exists?("#{@js_dir}/json.js").should be_true
64
+ # File.exists?("#{@js_dir}/cookie.js").should be_true
65
+ # File.read("#{@js_dir}/cookie.js").should == "Original cookie.js"
66
+ # end
67
+ # end
68
+ #end
@@ -0,0 +1,28 @@
1
+ require "test/unit"
2
+ require "rails/test_help"
3
+ require "cacheable_flash/test_helpers"
4
+
5
+ class TestController < ActionController::Base
6
+ include CacheableFlash
7
+
8
+ def index
9
+ flash["notice"] = "In index"
10
+ render :text => "WORKING!!!"
11
+ end
12
+ end
13
+
14
+ class ControllerTest < ActionController::TestCase
15
+ include CacheableFlash::TestHelpers
16
+
17
+ def setup
18
+ @controller = TestController.new
19
+ @request = ActionController::TestRequest.new
20
+ @response = ActionController::TestResponse.new
21
+ end
22
+
23
+ def test_cacheable_flash_action
24
+ get :index
25
+ assert_equal "In index", flash_cookie["notice"]
26
+ end
27
+ end
28
+
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env rake
2
- # Add your own tasks in files placed in lib/tasks ending in .rake,
3
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
-
5
- require File.expand_path('../config/application', __FILE__)
6
-
7
- Dummy::Application.load_tasks
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -1,15 +1,15 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
9
- //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require_tree .
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -1,13 +1,13 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -1,3 +1,3 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -1,2 +1,2 @@
1
- module ApplicationHelper
2
- end
1
+ module ApplicationHelper
2
+ end
@@ -1,14 +1,14 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application", :cacheable_flash %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application", :cacheable_flash %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -1,4 +1,4 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Dummy::Application
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -1,62 +1,62 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- # Pick the frameworks you want:
4
- #require "active_record/railtie"
5
- require "action_controller/railtie"
6
- #require "action_mailer/railtie"
7
- #require "active_resource/railtie"
8
- require "sprockets/railtie"
9
- # require "rails/test_unit/railtie"
10
-
11
- Bundler.require
12
- require "cacheable_flash"
13
-
14
- module Dummy
15
- class Application < Rails::Application
16
- # Settings in config/environments/* take precedence over those specified here.
17
- # Application configuration should go into files in config/initializers
18
- # -- all .rb files in that directory are automatically loaded.
19
-
20
- # Custom directories with classes and modules you want to be autoloadable.
21
- # config.autoload_paths += %W(#{config.root}/extras)
22
-
23
- # Only load the plugins named here, in the order given (default is alphabetical).
24
- # :all can be used as a placeholder for all plugins not explicitly named.
25
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
-
27
- # Activate observers that should always be running.
28
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
29
-
30
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
32
- # config.time_zone = 'Central Time (US & Canada)'
33
-
34
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
35
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
36
- # config.i18n.default_locale = :de
37
-
38
- # Configure the default encoding used in templates for Ruby 1.9.
39
- config.encoding = "utf-8"
40
-
41
- # Configure sensitive parameters which will be filtered from the log file.
42
- config.filter_parameters += [:password]
43
-
44
- # Use SQL instead of Active Record's schema dumper when creating the database.
45
- # This is necessary if your schema can't be completely dumped by the schema dumper,
46
- # like if you have constraints or database-specific column types
47
- # config.active_record.schema_format = :sql
48
-
49
- # Enforce whitelist mode for mass assignment.
50
- # This will create an empty whitelist of attributes available for mass-assignment for all models
51
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
52
- # parameters by using an attr_accessible or attr_protected declaration.
53
- # config.active_record.whitelist_attributes = true
54
-
55
- # Enable the asset pipeline
56
- config.assets.enabled = true
57
-
58
- # Version of your assets, change this if you want to expire all your assets
59
- config.assets.version = '1.0'
60
- end
61
- end
62
-
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ #require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ #require "action_mailer/railtie"
7
+ #require "active_resource/railtie"
8
+ require "sprockets/railtie"
9
+ # require "rails/test_unit/railtie"
10
+
11
+ Bundler.require
12
+ require "cacheable_flash"
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ # Settings in config/environments/* take precedence over those specified here.
17
+ # Application configuration should go into files in config/initializers
18
+ # -- all .rb files in that directory are automatically loaded.
19
+
20
+ # Custom directories with classes and modules you want to be autoloadable.
21
+ # config.autoload_paths += %W(#{config.root}/extras)
22
+
23
+ # Only load the plugins named here, in the order given (default is alphabetical).
24
+ # :all can be used as a placeholder for all plugins not explicitly named.
25
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
+
27
+ # Activate observers that should always be running.
28
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
29
+
30
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
32
+ # config.time_zone = 'Central Time (US & Canada)'
33
+
34
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
35
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
36
+ # config.i18n.default_locale = :de
37
+
38
+ # Configure the default encoding used in templates for Ruby 1.9.
39
+ config.encoding = "utf-8"
40
+
41
+ # Configure sensitive parameters which will be filtered from the log file.
42
+ config.filter_parameters += [:password]
43
+
44
+ # Use SQL instead of Active Record's schema dumper when creating the database.
45
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
46
+ # like if you have constraints or database-specific column types
47
+ # config.active_record.schema_format = :sql
48
+
49
+ # Enforce whitelist mode for mass assignment.
50
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
51
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
52
+ # parameters by using an attr_accessible or attr_protected declaration.
53
+ # config.active_record.whitelist_attributes = true
54
+
55
+ # Enable the asset pipeline
56
+ config.assets.enabled = true
57
+
58
+ # Version of your assets, change this if you want to expire all your assets
59
+ config.assets.version = '1.0'
60
+ end
61
+ end
62
+
@@ -1,10 +1,10 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
9
-
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
10
  $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,25 +1,25 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- # Warning: The database defined as "test" will be erased and
13
- # re-generated from your development database when you run "rake".
14
- # Do not set this db to the same as development or production.
15
- test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
20
-
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000