backstack 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +20 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +38 -0
  6. data/Rakefile +54 -0
  7. data/VERSION +1 -0
  8. data/art/bowling_pins.graffle +0 -0
  9. data/backstack.gemspec +127 -0
  10. data/lib/backstack.rb +161 -0
  11. data/lib/backstacklib.rb +115 -0
  12. data/test/neutral/helper.rb +27 -0
  13. data/test/neutral/test_backstacklib.rb +181 -0
  14. data/test/rails_root/.gitignore +4 -0
  15. data/test/rails_root/Gemfile +33 -0
  16. data/test/rails_root/Gemfile.lock +77 -0
  17. data/test/rails_root/README +256 -0
  18. data/test/rails_root/Rakefile +12 -0
  19. data/test/rails_root/app/controllers/application_controller.rb +7 -0
  20. data/test/rails_root/app/controllers/c1_controller.rb +8 -0
  21. data/test/rails_root/app/controllers/c2_controller.rb +11 -0
  22. data/test/rails_root/app/controllers/c3_controller.rb +17 -0
  23. data/test/rails_root/app/controllers/c4_controller.rb +22 -0
  24. data/test/rails_root/app/helpers/application_helper.rb +2 -0
  25. data/test/rails_root/app/helpers/c1_helper.rb +2 -0
  26. data/test/rails_root/app/helpers/c2_helper.rb +2 -0
  27. data/test/rails_root/app/helpers/c3_helper.rb +2 -0
  28. data/test/rails_root/app/helpers/c4_helper.rb +2 -0
  29. data/test/rails_root/app/views/c1/a.html.erb +1 -0
  30. data/test/rails_root/app/views/c2/b.html.erb +1 -0
  31. data/test/rails_root/app/views/c2/c.html.erb +1 -0
  32. data/test/rails_root/app/views/c3/d.html.erb +1 -0
  33. data/test/rails_root/app/views/c3/e.html.erb +1 -0
  34. data/test/rails_root/app/views/c3/f.html.erb +1 -0
  35. data/test/rails_root/app/views/c4/g.html.erb +1 -0
  36. data/test/rails_root/app/views/c4/h.html.erb +1 -0
  37. data/test/rails_root/app/views/c4/i.html.erb +1 -0
  38. data/test/rails_root/app/views/c4/j.html.erb +1 -0
  39. data/test/rails_root/app/views/layouts/_pins.html.erb +64 -0
  40. data/test/rails_root/app/views/layouts/application.html.erb +15 -0
  41. data/test/rails_root/config/application.rb +47 -0
  42. data/test/rails_root/config/boot.rb +6 -0
  43. data/test/rails_root/config/environment.rb +5 -0
  44. data/test/rails_root/config/environments/development.rb +26 -0
  45. data/test/rails_root/config/environments/production.rb +49 -0
  46. data/test/rails_root/config/environments/test.rb +35 -0
  47. data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
  48. data/test/rails_root/config/initializers/inflections.rb +10 -0
  49. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  50. data/test/rails_root/config/initializers/secret_token.rb +7 -0
  51. data/test/rails_root/config/initializers/session_store.rb +8 -0
  52. data/test/rails_root/config/locales/en.yml +5 -0
  53. data/test/rails_root/config/routes.rb +15 -0
  54. data/test/rails_root/config.ru +4 -0
  55. data/test/rails_root/db/seeds.rb +7 -0
  56. data/test/rails_root/lib/tasks/.gitkeep +0 -0
  57. data/test/rails_root/public/404.html +26 -0
  58. data/test/rails_root/public/422.html +26 -0
  59. data/test/rails_root/public/500.html +26 -0
  60. data/test/rails_root/public/favicon.ico +0 -0
  61. data/test/rails_root/public/images/rails.png +0 -0
  62. data/test/rails_root/public/javascripts/.gitkeep +0 -0
  63. data/test/rails_root/public/javascripts/application.js +0 -0
  64. data/test/rails_root/public/robots.txt +5 -0
  65. data/test/rails_root/public/stylesheets/.gitkeep +0 -0
  66. data/test/rails_root/public/stylesheets/application.css +27 -0
  67. data/test/rails_root/script/rails +6 -0
  68. data/test/rails_root/test/functional/c1_controller_test.rb +10 -0
  69. data/test/rails_root/test/functional/c2_controller_test.rb +15 -0
  70. data/test/rails_root/test/functional/c3_controller_test.rb +20 -0
  71. data/test/rails_root/test/functional/c4_controller_test.rb +24 -0
  72. data/test/rails_root/test/integration/backstack_test.rb +96 -0
  73. data/test/rails_root/test/performance/browsing_test.rb +9 -0
  74. data/test/rails_root/test/test_helper.rb +7 -0
  75. data/test/rails_root/test/unit/helpers/c1_helper_test.rb +4 -0
  76. data/test/rails_root/test/unit/helpers/c2_helper_test.rb +4 -0
  77. data/test/rails_root/test/unit/helpers/c3_helper_test.rb +4 -0
  78. data/test/rails_root/test/unit/helpers/c4_helper_test.rb +4 -0
  79. data/test/rails_root/vendor/plugins/.gitkeep +0 -0
  80. metadata +176 -0
@@ -0,0 +1,64 @@
1
+
2
+ <%
3
+
4
+ def smart_link_to(t, f)
5
+
6
+ if f == request.fullpath
7
+ link_to(t, f, :class => :here)
8
+ else
9
+ link_to(t, f)
10
+ end
11
+
12
+ end
13
+
14
+ %>
15
+
16
+
17
+ <%# trail demonstrating interator with block %>
18
+ <p class="trail" id="link_trail">
19
+ <% backstack_trail do |c| %>
20
+ <% if c[:fullpath] == request.fullpath %>
21
+ <%= c[:name] %> /
22
+ <% else %>
23
+ <%= smart_link_to(c[:name], c[:fullpath]) %> /
24
+ <% end %>
25
+ <% end %>
26
+ </p>
27
+
28
+
29
+ <%# trail demonstrating calling without block returns array, no links this time %>
30
+ <p class="trail" id="no_link_trail">
31
+
32
+ <% links = [] %>
33
+ <% backstack_trail.each {|c| links.push c[:name] } %>
34
+ <%= links.join(" / ").html_safe %>
35
+
36
+ </p>
37
+
38
+
39
+ <p>
40
+ <%= smart_link_to("g", "/c4/g") %>
41
+ <%= smart_link_to("h", "/c4/h") %>
42
+ <%= smart_link_to("i", "/c4/i") %>
43
+ <%= smart_link_to("j", "/c4/j") %>
44
+ </p>
45
+
46
+ <p>
47
+ <%= smart_link_to("d", "/c3/d") %>
48
+ <%= smart_link_to("e", "/c3/e") %>
49
+ <%= smart_link_to("f", "/c3/f") %>
50
+ </p>
51
+
52
+ <p>
53
+ <%= smart_link_to("b", "/c2/b") %>
54
+ <%= smart_link_to("c", "/c2/c") %>
55
+ </p>
56
+
57
+ <p>
58
+ <%= smart_link_to("a", "/c1/a") %>
59
+ </p>
60
+
61
+ <p>
62
+ <%= backstack_link("Back", :id=>"back") %>
63
+ </p>
64
+
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsRoot</title>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= render :partial => "layouts/pins" %>
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,47 @@
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 "rails/test_unit/railtie"
9
+
10
+ # If you have a Gemfile, require the gems listed there, including any gems
11
+ # you've limited to :test, :development, or :production.
12
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
13
+
14
+ module RailsRoot
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
+ # JavaScript files you want as :defaults (application.js is always included).
39
+ config.action_view.javascript_expansions[:defaults] = %w()
40
+
41
+ # Configure the default encoding used in templates for Ruby 1.9.
42
+ config.encoding = "utf-8"
43
+
44
+ # Configure sensitive parameters which will be filtered from the log file.
45
+ config.filter_parameters += [:password]
46
+ end
47
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsRoot::Application.initialize!
@@ -0,0 +1,26 @@
1
+ RailsRoot::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,49 @@
1
+ RailsRoot::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+
47
+ # Send deprecation notices to registered listeners
48
+ config.active_support.deprecation = :notify
49
+ end
@@ -0,0 +1,35 @@
1
+ RailsRoot::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ RailsRoot::Application.config.secret_token = '9d99818a14f7f95d7ff2e783ae8a3cb4ba26519d7fc272134cdef0ec3d7f885e67cd0416e1849274d5ccd74628cf4feaf42ef07acbaa3f557fbcef4ada9e9fe5'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ RailsRoot::Application.config.session_store :cookie_store, :key => '_rails_root_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # RailsRoot::Application.config.session_store :active_record_store
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,15 @@
1
+ RailsRoot::Application.routes.draw do
2
+
3
+ get "c4/g"
4
+
5
+ get "c4/h"
6
+
7
+ get "c4/i"
8
+
9
+ get "c4/j"
10
+
11
+ root :to => "c1#a"
12
+
13
+ match ':controller(/:action(/:id(.:format)))'
14
+
15
+ end
@@ -0,0 +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 RailsRoot::Application
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
File without changes
@@ -0,0 +1,27 @@
1
+
2
+ p {
3
+ font-size: 2em;
4
+ text-align: center;
5
+ }
6
+
7
+ p a {
8
+ margin: 1em;
9
+ padding: 5px;
10
+ border: solid 1px white; /* placeholder for red border */
11
+ text-decoration: none;
12
+ }
13
+
14
+ p .here {
15
+ border: solid 1px red;
16
+ }
17
+
18
+
19
+ p.trail {
20
+ text-align: left;
21
+ font-size: 1.5em;
22
+ }
23
+
24
+ p.trail a {
25
+ margin: 0;
26
+ padding: 0;
27
+ }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class C1ControllerTest < ActionController::TestCase
4
+
5
+ test "should get a" do
6
+ get :a
7
+ assert_response :success
8
+ end
9
+
10
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ class C2ControllerTest < ActionController::TestCase
4
+
5
+ test "should get b" do
6
+ get :b
7
+ assert_response :success
8
+ end
9
+
10
+ test "should get c" do
11
+ get :c
12
+ assert_response :success
13
+ end
14
+
15
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class C3ControllerTest < ActionController::TestCase
4
+
5
+ test "should get d" do
6
+ get :d
7
+ assert_response :success
8
+ end
9
+
10
+ test "should get e" do
11
+ get :e
12
+ assert_response :success
13
+ end
14
+
15
+ test "should get f" do
16
+ get :f
17
+ assert_response :success
18
+ end
19
+
20
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ class C4ControllerTest < ActionController::TestCase
4
+ test "should get g" do
5
+ get :g
6
+ assert_response :success
7
+ end
8
+
9
+ test "should get h" do
10
+ get :h
11
+ assert_response :success
12
+ end
13
+
14
+ test "should get i" do
15
+ get :i
16
+ assert_response :success
17
+ end
18
+
19
+ test "should get j" do
20
+ get :j
21
+ assert_response :success
22
+ end
23
+
24
+ end
@@ -0,0 +1,96 @@
1
+ require 'test_helper'
2
+
3
+ class BackstackTest < ActionDispatch::IntegrationTest
4
+
5
+ # My hackpologies, this is just dizzying. Hard to see patterns to
6
+ # spot errors.
7
+ def test_backstack_meandering
8
+
9
+ # DRYer lambdas
10
+ aback = lambda {|x| ['a#back[href=?]', x.to_s] } # testing backstack_link
11
+ nolink = lambda {|x| ['#no_link_trail', x.to_s] } # testing backstack_trail
12
+
13
+ get '/'
14
+ assert_select 'a#back', :count => 0 # means no back link
15
+ assert_select *nolink['Alpha']
16
+
17
+ get '/c2/c'
18
+ assert_select *aback['/']
19
+ assert_select *nolink['Alpha / Charlie']
20
+
21
+ # testing clicky trail
22
+ assert_select '#link_trail' do
23
+ assert_select "a[href='/']", 'Alpha'
24
+ end
25
+
26
+ get '/c2/b'
27
+ assert_select *aback['/']
28
+ assert_select *nolink['Alpha / Bravo']
29
+
30
+ get '/'
31
+ assert_select 'a#back', :count => 0
32
+ assert_select *nolink['Alpha']
33
+
34
+ get '/c2/c'
35
+ assert_select *aback['/']
36
+ assert_select *nolink['Alpha / Charlie']
37
+
38
+ get '/c3/f'
39
+ assert_select *aback['/c2/c']
40
+ assert_select *nolink['Alpha / Charlie / Foxtrot']
41
+
42
+ # testing clicky trail
43
+ assert_select '#link_trail' do
44
+ assert_select "a[href='/']", 'Alpha'
45
+ assert_select "a[href='/c2/c']", 'Charlie'
46
+ end
47
+
48
+ get '/c4/j'
49
+ assert_select *aback['/c3/f']
50
+ assert_select *nolink['Alpha / Charlie / Foxtrot / Juliet']
51
+ get '/c4/i'
52
+ assert_select *aback['/c3/f']
53
+ assert_select *nolink['Alpha / Charlie / Foxtrot / India']
54
+ get '/c4/h'
55
+ assert_select *aback['/c3/f']
56
+ assert_select *nolink['Alpha / Charlie / Foxtrot / Hotel']
57
+ get '/c4/g'
58
+ assert_select *aback['/c3/f']
59
+ assert_select *nolink['Alpha / Charlie / Foxtrot / Golf']
60
+
61
+ # testing clicky trail
62
+ assert_select '#link_trail' do
63
+ assert_select "a[href='/']", 'Alpha'
64
+ assert_select "a[href='/c2/c']", 'Charlie'
65
+ assert_select "a[href='/c3/f']", 'Foxtrot'
66
+ end
67
+
68
+ get '/c3/f'
69
+ assert_select *aback['/c2/c']
70
+ assert_select *nolink['Alpha / Charlie / Foxtrot']
71
+ get '/c3/d'
72
+ assert_select *aback['/c2/c']
73
+ assert_select *nolink['Alpha / Charlie / Delta']
74
+ get '/c3/e'
75
+ assert_select *aback['/c2/c']
76
+ assert_select *nolink['Alpha / Charlie / Echo']
77
+
78
+ # testing clicky trail
79
+ assert_select '#link_trail' do
80
+ assert_select "a[href='/']", 'Alpha'
81
+ assert_select "a[href='/c2/c']", 'Charlie'
82
+ end
83
+
84
+ get '/c2/c'
85
+ assert_select *aback['/']
86
+
87
+ get '/'
88
+ assert_select 'a#back', :count => 0 # means no back link
89
+ assert_select *nolink['Alpha']
90
+
91
+ end
92
+
93
+
94
+
95
+
96
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionDispatch::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end