gretel 3.0.6 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Gretel
2
- VERSION = "3.0.6"
3
- end
2
+ VERSION = "4.0.1"
3
+ end
@@ -10,10 +10,6 @@ module Gretel
10
10
  def breadcrumb(key = nil, *args)
11
11
  if key.nil? || key.is_a?(Hash)
12
12
  raise ArgumentError, "The `breadcrumb` method was called with #{key.inspect} as the key. This method is used to set the breadcrumb. Maybe you meant to call the `breadcrumbs` method (with an 's' in the end) which is used to render the breadcrumbs?"
13
- elsif key.class.respond_to?(:model_name)
14
- # Enables calling `breadcrumb @product` instead of `breadcrumb :product, @product`
15
- args.unshift key
16
- key = key.class.model_name.to_s.underscore.to_sym
17
13
  end
18
14
  @_gretel_renderer = Gretel::Renderer.new(self, key, *args)
19
15
  end
@@ -7,53 +7,8 @@ require "gretel"
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Custom directories with classes and modules you want to be autoloadable.
15
- # config.autoload_paths += %W(#{config.root}/extras)
16
-
17
- # Only load the plugins named here, in the order given (default is alphabetical).
18
- # :all can be used as a placeholder for all plugins not explicitly named.
19
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
-
21
- # Activate observers that should always be running.
22
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
-
24
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
- # config.time_zone = 'Central Time (US & Canada)'
27
-
28
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
- # config.i18n.default_locale = :de
31
-
32
- # Configure the default encoding used in templates for Ruby 1.9.
33
- config.encoding = "utf-8"
34
-
35
- # Configure sensitive parameters which will be filtered from the log file.
36
- config.filter_parameters += [:password]
37
-
38
- # Enable escaping HTML in JSON.
39
- config.active_support.escape_html_entities_in_json = true
40
-
41
- # Use SQL instead of Active Record's schema dumper when creating the database.
42
- # This is necessary if your schema can't be completely dumped by the schema dumper,
43
- # like if you have constraints or database-specific column types
44
- # config.active_record.schema_format = :sql
45
-
46
- # Enforce whitelist mode for mass assignment.
47
- # This will create an empty whitelist of attributes available for mass-assignment for all models
48
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
49
- # parameters by using an attr_accessible or attr_protected declaration.
50
- config.active_record.whitelist_attributes = true
51
-
52
- # Enable the asset pipeline
53
- config.assets.enabled = true
54
-
55
- # Version of your assets, change this if you want to expire all your assets
56
- config.assets.version = '1.0'
10
+ config.secret_token = "secret token"
11
+ config.active_support.deprecation = :log
12
+ config.eager_load = false
57
13
  end
58
14
  end
59
-
@@ -77,4 +77,9 @@ end
77
77
  crumb :with_link_options do
78
78
  link "Test", about_path, title: "My Title", other: "Other Option"
79
79
  link "Other Link", some_option: "Test"
80
+ end
81
+
82
+ crumb :with_inferred_parent do
83
+ link "Test", about_path
84
+ parent Project.first
80
85
  end
@@ -1,37 +1,2 @@
1
1
  Dummy::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 web server 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_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger
20
- config.active_support.deprecation = :log
21
-
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
-
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
31
-
32
- # Do not compress assets
33
- config.assets.compress = false
34
-
35
- # Expands the lines which load the assets
36
- config.assets.debug = true
37
2
  end
@@ -1,67 +1,2 @@
1
1
  Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
6
-
7
- # Full error reports are disabled and caching is turned on
8
- config.consider_all_requests_local = false
9
- config.action_controller.perform_caching = true
10
-
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
13
-
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
16
-
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
18
- config.assets.compile = false
19
-
20
- # Generate digests for assets URLs
21
- config.assets.digest = true
22
-
23
- # Defaults to nil and saved in location specified by config.assets.prefix
24
- # config.assets.manifest = YOUR_PATH
25
-
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
-
30
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
- # config.force_ssl = true
32
-
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
35
-
36
- # Prepend all log lines with the following tags
37
- # config.log_tags = [ :subdomain, :uuid ]
38
-
39
- # Use a different logger for distributed setups
40
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
-
42
- # Use a different cache store in production
43
- # config.cache_store = :mem_cache_store
44
-
45
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
- # config.action_controller.asset_host = "http://assets.example.com"
47
-
48
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
- # config.assets.precompile += %w( search.js )
50
-
51
- # Disable delivery errors, bad email addresses will be ignored
52
- # config.action_mailer.raise_delivery_errors = false
53
-
54
- # Enable threaded mode
55
- # config.threadsafe!
56
-
57
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
- # the I18n.default_locale when a translation can not be found)
59
- config.i18n.fallbacks = true
60
-
61
- # Send deprecation notices to registered listeners
62
- config.active_support.deprecation = :notify
63
-
64
- # Log the query plan for queries taking more than this (works
65
- # with SQLite, MySQL, and PostgreSQL)
66
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
67
2
  end
@@ -1,37 +1,2 @@
1
1
  Dummy::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
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
13
-
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
16
-
17
- # Show full error reports and disable caching
18
- config.consider_all_requests_local = true
19
- config.action_controller.perform_caching = false
20
-
21
- # Raise exceptions instead of rendering exception templates
22
- config.action_dispatch.show_exceptions = false
23
-
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
-
27
- # Tell Action Mailer not to deliver emails to the real world.
28
- # The :test delivery method accumulates sent emails in the
29
- # ActionMailer::Base.deliveries array.
30
- config.action_mailer.delivery_method = :test
31
-
32
- # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
34
-
35
- # Print deprecation notices to the stderr
36
- config.active_support.deprecation = :stderr
37
2
  end
@@ -1,11 +1,11 @@
1
1
  Dummy::Application.routes.draw do
2
2
  root to: "dummy#dummy"
3
3
 
4
- match "about" => "dummy#dummy", as: :about
5
- match "about/contact" => "dummy#dummy", as: :contact
6
- match "about/contact/form" => "dummy#dummy", as: :contact_form
4
+ get "about" => "dummy#dummy", as: :about
5
+ get "about/contact" => "dummy#dummy", as: :contact
6
+ get "about/contact/form" => "dummy#dummy", as: :contact_form
7
7
 
8
8
  resources :projects do
9
9
  resources :issues
10
10
  end
11
- end
11
+ end
@@ -1,4 +1,4 @@
1
- class CreateProjects < ActiveRecord::Migration
1
+ class CreateProjects < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :projects do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateIssues < ActiveRecord::Migration
1
+ class CreateIssues < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :issues do |t|
4
4
  t.string :title
@@ -1,29 +1,28 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
5
4
  #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
5
+ # This file is the source Rails uses to define your schema when running `rails
6
+ # db:schema:load`. When creating a new database, `rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
11
10
  #
12
- # It's strongly recommended to check this file into your version control system.
11
+ # It's strongly recommended that you check this file into your version control system.
13
12
 
14
- ActiveRecord::Schema.define(:version => 20130122163051) do
13
+ ActiveRecord::Schema.define(version: 2013_01_22_163051) do
15
14
 
16
- create_table "issues", :force => true do |t|
17
- t.string "title"
18
- t.integer "project_id"
19
- t.datetime "created_at", :null => false
20
- t.datetime "updated_at", :null => false
15
+ create_table "issues", force: :cascade do |t|
16
+ t.string "title"
17
+ t.integer "project_id"
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
21
20
  end
22
21
 
23
- create_table "projects", :force => true do |t|
24
- t.string "name"
25
- t.datetime "created_at", :null => false
26
- t.datetime "updated_at", :null => false
22
+ create_table "projects", force: :cascade do |t|
23
+ t.string "name"
24
+ t.datetime "created_at"
25
+ t.datetime "updated_at"
27
26
  end
28
27
 
29
28
  end
@@ -11,7 +11,6 @@ class GretelTest < ActiveSupport::TestCase
11
11
  Rails.root.join("app", "views", "breadcrumbs", "**", "*.rb")],
12
12
  Gretel.breadcrumb_paths[-3..-1]
13
13
  assert_equal ["development"], Gretel.reload_environments
14
- assert !Gretel.suppress_deprecation_warnings?
15
14
  end
16
15
 
17
16
  test "configuration block" do
@@ -21,4 +20,4 @@ class GretelTest < ActiveSupport::TestCase
21
20
 
22
21
  assert_equal ["development", "staging"], Gretel.reload_environments
23
22
  end
24
- end
23
+ end
@@ -2,7 +2,10 @@ require 'test_helper'
2
2
 
3
3
  class HelperMethodsTest < ActionView::TestCase
4
4
  include Gretel::ViewHelpers
5
+
6
+ self.fixture_path = File.expand_path("../../test/fixtures", __FILE__)
5
7
  fixtures :all
8
+
6
9
  helper :application
7
10
 
8
11
  setup do
@@ -11,131 +14,149 @@ class HelperMethodsTest < ActionView::TestCase
11
14
 
12
15
  # Breadcrumb generation
13
16
 
14
- test "shows basic breadcrumb" do
17
+ test "basic breadcrumb" do
15
18
  breadcrumb :basic
16
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
19
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
17
20
  breadcrumbs.to_s
18
21
  end
19
22
 
20
- test "shows breadcrumb with root" do
23
+ test "breadcrumb with root" do
21
24
  breadcrumb :with_root
22
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
25
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
23
26
  breadcrumbs.to_s
24
27
  end
25
28
 
26
- test "shows breadcrumb with parent" do
29
+ test "breadcrumb with parent" do
27
30
  breadcrumb :with_parent
28
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about">About</a> &rsaquo; <span class="current">Contact</span></div>},
31
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about">About</a> &rsaquo; <span class="current">Contact</span></div>},
29
32
  breadcrumbs.to_s
30
33
  end
31
34
 
32
- test "shows breadcrumb with autopath" do
35
+ test "breadcrumb with autopath" do
33
36
  breadcrumb :with_autopath, projects(:one)
34
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test Project</span></div>},
37
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test Project</span></div>},
35
38
  breadcrumbs.to_s
36
39
  end
37
40
 
38
- test "shows breadcrumb with parent object" do
41
+ test "breadcrumb with parent object" do
39
42
  breadcrumb :with_parent_object, issues(:one)
40
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/projects/1">Test Project</a> &rsaquo; <span class="current">Test Issue</span></div>},
43
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/projects/1">Test Project</a> &rsaquo; <span class="current">Test Issue</span></div>},
41
44
  breadcrumbs.to_s
42
45
  end
43
46
 
44
- test "shows multiple links" do
47
+ test "multiple links" do
45
48
  breadcrumb :multiple_links
46
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about/contact">Contact</a> &rsaquo; <span class="current">Contact form</span></div>},
49
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about/contact">Contact</a> &rsaquo; <span class="current">Contact form</span></div>},
47
50
  breadcrumbs.to_s
48
51
  end
49
52
 
50
- test "shows multiple links with parent" do
53
+ test "multiple links with parent" do
51
54
  breadcrumb :multiple_links_with_parent
52
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about">About</a> &rsaquo; <a href="/about/contact">Contact</a> &rsaquo; <span class="current">Contact form</span></div>},
55
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about">About</a> &rsaquo; <a href="/about/contact">Contact</a> &rsaquo; <span class="current">Contact form</span></div>},
53
56
  breadcrumbs.to_s
54
57
  end
55
58
 
56
- test "shows semantic breadcrumb" do
59
+ test "semantic breadcrumb" do
57
60
  breadcrumb :with_root
58
- assert_equal %{<div class="breadcrumbs"><span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/" itemprop="url"><span itemprop="title">Home</span></a></span> &rsaquo; <span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><span class="current" itemprop="title">About</span></span></div>},
61
+ assert_dom_equal %{<div class="breadcrumbs" itemscope="itemscope" itemtype="https://schema.org/BreadcrumbList"><span itemprop="itemListElement" itemscope="itemscope" itemtype="https://schema.org/ListItem"><a itemprop="item" href="/"><span itemprop="name">Home</span></a><meta itemprop="position" content="1" /></span> &rsaquo; <span class="current" itemprop="itemListElement" itemscope="itemscope" itemtype="https://schema.org/ListItem"><span itemprop="name">About</span><meta itemprop="item" content="http://test.host/about" /><meta itemprop="position" content="2" /></span></div>},
59
62
  breadcrumbs(semantic: true).to_s
60
63
  end
61
64
 
62
65
  test "doesn't show root alone" do
63
66
  breadcrumb :root
64
- assert_equal "", breadcrumbs.to_s
67
+ assert_dom_equal "", breadcrumbs.to_s
65
68
  end
66
69
 
67
70
  test "displays single fragment" do
68
71
  breadcrumb :root
69
- assert_equal %{<div class="breadcrumbs"><span class="current">Home</span></div>},
72
+ assert_dom_equal %{<div class="breadcrumbs"><span class="current">Home</span></div>},
70
73
  breadcrumbs(display_single_fragment: true).to_s
71
74
  end
72
75
 
73
76
  test "displays single non-root fragment" do
74
77
  breadcrumb :basic
75
- assert_equal %{<div class="breadcrumbs"><span class="current">About</span></div>},
78
+ assert_dom_equal %{<div class="breadcrumbs"><span class="current">About</span></div>},
76
79
  breadcrumbs(autoroot: false, display_single_fragment: true).to_s
77
80
  end
78
81
 
79
- test "shows no breadcrumb" do
80
- assert_equal "", breadcrumbs.to_s
82
+ test "no breadcrumb" do
83
+ assert_dom_equal "", breadcrumbs.to_s
81
84
  end
82
85
 
83
86
  test "links current breadcrumb" do
84
87
  breadcrumb :with_root
85
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about" class="current">About</a></div>},
88
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about" class="current">About</a></div>},
86
89
  breadcrumbs(link_current: true).to_s
87
90
  end
88
91
 
89
- test "shows pretext" do
92
+ test "pretext" do
90
93
  breadcrumb :basic
91
- assert_equal %{<div class="breadcrumbs"><span class="pretext">You are here:</span> <a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
94
+ assert_dom_equal %{<div class="breadcrumbs"><span class="pretext">You are here:</span> <a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
92
95
  breadcrumbs(pretext: "You are here:").to_s
93
96
  end
94
97
 
95
- test "shows posttext" do
98
+ test "posttext" do
96
99
  breadcrumb :basic
97
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span> <span class="posttext">text after breadcrumbs</span></div>},
100
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span> <span class="posttext">text after breadcrumbs</span></div>},
98
101
  breadcrumbs(posttext: "text after breadcrumbs").to_s
99
102
  end
100
103
 
101
104
  test "autoroot disabled" do
102
105
  breadcrumb :basic
103
- assert_equal "", breadcrumbs(autoroot: false).to_s
106
+ assert_dom_equal "", breadcrumbs(autoroot: false).to_s
104
107
  end
105
108
 
106
- test "shows separator" do
109
+ test "separator" do
107
110
  breadcrumb :with_root
108
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &raquo; <span class="current">About</span></div>},
111
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &raquo; <span class="current">About</span></div>},
109
112
  breadcrumbs(separator: " &raquo; ").to_s
110
113
  end
111
114
 
112
- test "shows element id" do
115
+ test "element id" do
113
116
  breadcrumb :basic
114
- assert_equal %{<div class="breadcrumbs" id="custom_id"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
117
+ assert_dom_equal %{<div class="breadcrumbs" id="custom_id"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
115
118
  breadcrumbs(id: "custom_id").to_s
116
119
  end
117
120
 
118
- test "shows custom container class" do
121
+ test "custom container class" do
119
122
  breadcrumb :basic
120
- assert_equal %{<div class="custom_class"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
123
+ assert_dom_equal %{<div class="custom_class"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
121
124
  breadcrumbs(class: "custom_class").to_s
122
125
  end
123
126
 
124
- test "shows custom current class" do
127
+ test "custom fragment class" do
125
128
  breadcrumb :basic
126
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="custom_current_class">About</span></div>},
129
+ assert_dom_equal %{<div class="breadcrumbs"><a class="custom_fragment_class" href="/">Home</a> &rsaquo; <span class="custom_fragment_class current">About</span></div>},
130
+ breadcrumbs(fragment_class: "custom_fragment_class").to_s
131
+ end
132
+
133
+ test "custom current class" do
134
+ breadcrumb :basic
135
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="custom_current_class">About</span></div>},
127
136
  breadcrumbs(current_class: "custom_current_class").to_s
128
137
  end
129
138
 
139
+ test "custom pretext class" do
140
+ breadcrumb :basic
141
+ assert_dom_equal %{<div class="breadcrumbs"><span class="custom_pretext_class">You are here:</span> <a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
142
+ breadcrumbs(pretext: "You are here:", pretext_class: "custom_pretext_class").to_s
143
+ end
144
+
145
+ test "custom posttext class" do
146
+ breadcrumb :basic
147
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span> <span class="custom_posttext_class">after breadcrumbs</span></div>},
148
+ breadcrumbs(posttext: "after breadcrumbs", posttext_class: "custom_posttext_class").to_s
149
+ end
150
+
130
151
  test "unsafe html" do
131
152
  breadcrumb :with_unsafe_html
132
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test &lt;strong&gt;bold text&lt;/strong&gt;</span></div>},
153
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test &lt;strong&gt;bold text&lt;/strong&gt;</span></div>},
133
154
  breadcrumbs.to_s
134
155
  end
135
156
 
136
157
  test "safe html" do
137
158
  breadcrumb :with_safe_html
138
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test <strong>bold text</strong></span></div>},
159
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test <strong>bold text</strong></span></div>},
139
160
  breadcrumbs.to_s
140
161
  end
141
162
 
@@ -167,7 +188,9 @@ class HelperMethodsTest < ActionView::TestCase
167
188
  breadcrumb :basic
168
189
 
169
190
  out = parent_breadcrumb(autoroot: false) do
191
+ # :nocov:
170
192
  "yielded"
193
+ # :nocov:
171
194
  end
172
195
 
173
196
  assert_nil out
@@ -199,10 +222,10 @@ class HelperMethodsTest < ActionView::TestCase
199
222
  links[0].tap do |link|
200
223
  assert link.title?
201
224
  assert_equal "My Title", link.title
202
-
225
+
203
226
  assert link.other?
204
227
  assert_equal "Other Option", link.other
205
-
228
+
206
229
  assert !link.nonexistent?
207
230
  assert_nil link.nonexistent
208
231
  end
@@ -213,53 +236,53 @@ class HelperMethodsTest < ActionView::TestCase
213
236
  end
214
237
  end
215
238
 
216
- assert_equal %{<div class="breadcrumbs"><a href="/about">Test</a> &rsaquo; <span class="current">Other Link</span></div>},
239
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/about">Test</a> &rsaquo; <span class="current">Other Link</span></div>},
217
240
  breadcrumbs(autoroot: false).to_s
218
241
  end
219
242
 
220
243
  test "without link" do
221
244
  breadcrumb :without_link
222
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; Also without link &rsaquo; <span class="current">Without link</span></div>},
245
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; Also without link &rsaquo; <span class="current">Without link</span></div>},
223
246
  breadcrumbs.to_s
224
247
  end
225
248
 
226
249
  test "view context" do
227
250
  breadcrumb :using_view_helper
228
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">TestTest</span></div>},
251
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">TestTest</span></div>},
229
252
  breadcrumbs.to_s
230
253
  end
231
254
 
232
255
  test "multiple arguments" do
233
256
  breadcrumb :with_multiple_arguments, "One", "Two", "Three"
234
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about">First OneOne then TwoTwo then ThreeThree</a> &rsaquo; <span class="current">One and Two and Three</span></div>},
257
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about">First OneOne then TwoTwo then ThreeThree</a> &rsaquo; <span class="current">One and Two and Three</span></div>},
235
258
  breadcrumbs.to_s
236
259
  end
237
260
 
238
261
  test "from views folder" do
239
262
  breadcrumb :from_views
240
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Breadcrumb From View</span></div>},
263
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Breadcrumb From View</span></div>},
241
264
  breadcrumbs.to_s
242
265
  end
243
266
 
244
267
  test "with_breadcrumb" do
245
268
  breadcrumb :basic
246
-
247
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
269
+
270
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
248
271
  breadcrumbs.to_s
249
272
 
250
273
  with_breadcrumb(:with_parent_object, issues(:one)) do
251
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/projects/1">Test Project</a> &rsaquo; <span class="current">Test Issue</span></div>},
274
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/projects/1">Test Project</a> &rsaquo; <span class="current">Test Issue</span></div>},
252
275
  breadcrumbs.to_s
253
- end
254
-
255
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
276
+ end
277
+
278
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
256
279
  breadcrumbs.to_s
257
280
  end
258
281
 
259
282
  test "calling breadcrumbs helper twice" do
260
283
  breadcrumb :with_parent
261
284
  2.times do
262
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about">About</a> &rsaquo; <span class="current">Contact</span></div>},
285
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/about">About</a> &rsaquo; <span class="current">Contact</span></div>},
263
286
  breadcrumbs.to_s
264
287
  end
265
288
  end
@@ -278,6 +301,13 @@ class HelperMethodsTest < ActionView::TestCase
278
301
  assert_equal "/testpath?a=1&b=2", breadcrumbs.last.url
279
302
  end
280
303
 
304
+ test "current link url is not set to fullpath using link_current_to_request_path=false" do
305
+ self.request = OpenStruct.new(fullpath: "/testpath?a=1&b=2")
306
+
307
+ breadcrumb :basic
308
+ assert_equal "/about", breadcrumbs(:link_current_to_request_path => false).last.url
309
+ end
310
+
281
311
  test "calling the breadcrumb method with wrong arguments" do
282
312
  assert_nothing_raised do
283
313
  breadcrumb :basic, test: 1
@@ -294,51 +324,64 @@ class HelperMethodsTest < ActionView::TestCase
294
324
 
295
325
  test "inferred breadcrumb" do
296
326
  breadcrumb Project.first
297
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test Project</span></div>},
327
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test Project</span></div>},
298
328
  breadcrumbs.to_s
299
329
  end
300
330
 
331
+ test "inferred parent" do
332
+ breadcrumb :with_inferred_parent
333
+
334
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/projects/1">Test Project</a> &rsaquo; <span class="current">Test</span></div>},
335
+ breadcrumbs.to_s
336
+ end
337
+
301
338
  # Styles
302
339
 
303
340
  test "default style" do
304
341
  breadcrumb :basic
305
- assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
342
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">About</span></div>},
306
343
  breadcrumbs.to_s
307
344
  end
308
345
 
309
346
  test "ordered list style" do
310
347
  breadcrumb :basic
311
- assert_equal %{<ol class="breadcrumbs"><li><a href="/">Home</a></li><li class="current">About</li></ol>},
348
+ assert_dom_equal %{<ol class="breadcrumbs"><li><a href="/">Home</a></li><li class="current">About</li></ol>},
312
349
  breadcrumbs(style: :ol).to_s
313
350
  end
314
351
 
315
352
  test "unordered list style" do
316
353
  breadcrumb :basic
317
- assert_equal %{<ul class="breadcrumbs"><li><a href="/">Home</a></li><li class="current">About</li></ul>},
354
+ assert_dom_equal %{<ul class="breadcrumbs"><li><a href="/">Home</a></li><li class="current">About</li></ul>},
318
355
  breadcrumbs(style: :ul).to_s
319
356
  end
320
357
 
321
358
  test "bootstrap style" do
322
359
  breadcrumb :basic
323
- assert_equal %{<ol class="breadcrumb"><li><a href="/">Home</a></li><li class="active">About</li></ol>},
360
+ assert_dom_equal %{<ol class="breadcrumb"><li><a href="/">Home</a></li><li class="active">About</li></ol>},
324
361
  breadcrumbs(style: :bootstrap).to_s
325
362
  end
326
363
 
364
+ test "bootstrap4 style" do
365
+ breadcrumb :basic
366
+ assert_dom_equal %{<ol class="breadcrumb"><li class="breadcrumb-item"><a href="/">Home</a></li><li class="breadcrumb-item active">About</li></ol>},
367
+ breadcrumbs(style: :bootstrap4).to_s
368
+ end
369
+
327
370
  test "foundation5 style" do
328
371
  breadcrumb :basic
329
- assert_equal %{<ul class="breadcrumbs"><li><a href="/">Home</a></li><li class="current">About</li></ul>},
330
- breadcrumbs(style: :foundation5).to_s
372
+ assert_dom_equal %{<ul class="breadcrumbs"><li><a href="/">Home</a></li><li class="current">About</li></ul>},
373
+ breadcrumbs(style: :foundation5).to_s
331
374
  end
332
375
 
333
376
  test "custom container and fragment tags" do
334
377
  breadcrumb :basic
335
- assert_equal %{<c class="breadcrumbs"><f><a href="/">Home</a></f> &rsaquo; <f class="current">About</f></c>},
378
+ assert_dom_equal %{<c class="breadcrumbs"><f><a href="/">Home</a></f> &rsaquo; <f class="current">About</f></c>},
336
379
  breadcrumbs(container_tag: :c, fragment_tag: :f).to_s
337
380
  end
338
381
 
339
382
  test "custom semantic container and fragment tags" do
340
383
  breadcrumb :basic
341
- assert_equal %{<c class="breadcrumbs"><f itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/" itemprop="url"><span itemprop="title">Home</span></a></f> &rsaquo; <f class="current" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">About</span></f></c>},
384
+ assert_dom_equal %{<c class="breadcrumbs" itemscope="itemscope" itemtype="https://schema.org/BreadcrumbList"><f itemprop="itemListElement" itemscope="itemscope" itemtype="https://schema.org/ListItem"><a itemprop="item" href="/"><span itemprop="name">Home</span></a><meta itemprop="position" content="1" /></f> &rsaquo; <f class="current" itemprop="itemListElement" itemscope="itemscope" itemtype="https://schema.org/ListItem"><span itemprop="name">About</span><meta itemprop="item" content="http://test.host/about" /><meta itemprop="position" content="2" /></f></c>},
342
385
  breadcrumbs(container_tag: :c, fragment_tag: :f, semantic: true).to_s
343
386
  end
344
387
 
@@ -351,10 +394,10 @@ class HelperMethodsTest < ActionView::TestCase
351
394
 
352
395
  test "register style" do
353
396
  Gretel.register_style :test_style, { container_tag: :one, fragment_tag: :two }
354
-
397
+
355
398
  breadcrumb :basic
356
399
 
357
- assert_equal %{<one class="breadcrumbs"><two><a href="/">Home</a></two><two class="current">About</two></one>},
400
+ assert_dom_equal %{<one class="breadcrumbs"><two><a href="/">Home</a></two><two class="current">About</two></one>},
358
401
  breadcrumbs(style: :test_style).to_s
359
402
  end
360
403
 
@@ -376,7 +419,7 @@ class HelperMethodsTest < ActionView::TestCase
376
419
  end
377
420
 
378
421
  breadcrumb :about
379
- assert_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
422
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
380
423
 
381
424
  sleep 1 # File change interval is 1 second
382
425
 
@@ -392,7 +435,7 @@ class HelperMethodsTest < ActionView::TestCase
392
435
  end
393
436
 
394
437
  breadcrumb :about
395
- assert_equal %{<div class="breadcrumbs"><a href="/test">Home (reloaded)</a> &rsaquo; <span class="current">About (reloaded)</span></div>}, breadcrumbs.to_s
438
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/test">Home (reloaded)</a> &rsaquo; <span class="current">About (reloaded)</span></div>}, breadcrumbs.to_s
396
439
  end
397
440
 
398
441
  test "reload configuration when file is added" do
@@ -421,7 +464,7 @@ class HelperMethodsTest < ActionView::TestCase
421
464
  end
422
465
 
423
466
  breadcrumb :about
424
- assert_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
467
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
425
468
  end
426
469
 
427
470
  test "reload configuration when file is deleted" do
@@ -449,7 +492,7 @@ class HelperMethodsTest < ActionView::TestCase
449
492
  end
450
493
 
451
494
  breadcrumb :contact
452
- assert_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <a href="/about">About (loaded)</a> &rsaquo; <span class="current">Contact (loaded)</span></div>}, breadcrumbs.to_s
495
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <a href="/about">About (loaded)</a> &rsaquo; <span class="current">Contact (loaded)</span></div>}, breadcrumbs.to_s
453
496
 
454
497
  File.delete path.join("pages.rb")
455
498
 
@@ -459,7 +502,7 @@ class HelperMethodsTest < ActionView::TestCase
459
502
  end
460
503
 
461
504
  breadcrumb :about
462
- assert_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
505
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
463
506
  end
464
507
 
465
508
  test "reloads only in development environment" do
@@ -479,7 +522,7 @@ class HelperMethodsTest < ActionView::TestCase
479
522
  end
480
523
 
481
524
  breadcrumb :about
482
- assert_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
525
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
483
526
 
484
527
  sleep 1
485
528
 
@@ -495,7 +538,7 @@ class HelperMethodsTest < ActionView::TestCase
495
538
  end
496
539
 
497
540
  breadcrumb :about
498
- assert_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
541
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home (loaded)</a> &rsaquo; <span class="current">About (loaded)</span></div>}, breadcrumbs.to_s
499
542
  end
500
543
 
501
544
  private