auto_breadcrumbs 0.0.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c84bd6b796c253c40ac1b1511d03a83f58ea9698
4
- data.tar.gz: 68254ba6d275a6ea33a07bff0f13307f488eba24
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTA2OTFlNjRlYWFjZjY3ZTZjMDhlNjdjM2ZiZDAwMzYwZjRjZGYzOA==
5
+ data.tar.gz: !binary |-
6
+ YWMzOWE0OGQzYTNjNjZhMjAyMDdjZGQ5OTUyNDY1MTdiYjllNGJkZg==
5
7
  SHA512:
6
- metadata.gz: dae146312d466ecab2ca5d08ce706ad1f85875e952db0dcbc18b6d02e536a293b3b564c8959f4e42169039f40f9240a37223f07d4d2ea4c0656dc57a153e02d2
7
- data.tar.gz: 9d2aba78058ec04c3608cb1dda7086670ccdf5d00272d2c28d907ecdf41d3bd1e9b02cd65de89da4d83971583ee17cdcbc21b20981c192a157cc4b6c67ca82f6
8
+ metadata.gz: !binary |-
9
+ NWFhMDA5Yjc4MmRkYWZlMjFkN2M3ZDY5ZmE3Nzg5ZDY2MzgyYjVjMzM2NDM5
10
+ YjlmYTJmM2RmNjk4OTY2M2FkYTFmNjgwZDJhMWE3MWFlOTNmZDgxZWRiMTVj
11
+ MjViYzFhY2Q0M2IzNTA0OGIyNmUwZGQ4OTNhYjgwZjk1Y2UyZDU=
12
+ data.tar.gz: !binary |-
13
+ OGQ5ZWZkNmIzNzY2MjU0ZGJhYmU2Y2U1MzAxMGU4N2FmMmUzOTE2N2UyMWJi
14
+ Y2ExNTRiZTk5ZWViZjAyOTMxYzZlMjFlOTM0ZmY0YmY3Y2IyZTcxYzYwMTk5
15
+ ZmFkNTA2Y2E1MDg0NDU1YjhiYmVhNjY5NzI4MDAwOTQyNzk0ZjU=
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ before_install: "gem update --system"
6
+ install: "bundle install"
7
+ script: "bundle exec rspec"
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # AutoBreadcrumbs
1
+ # Auto Breadcrumbs [![Build Status](https://travis-ci.org/exAspArk/auto_breadcrumbs.png)](https://travis-ci.org/exAspArk/auto_breadcrumbs)
2
2
 
3
3
  Automatically add breadcrumbs to each page by using locales and gem `breadcrumbs_on_rails`.
4
4
 
@@ -14,13 +14,7 @@ And then execute:
14
14
 
15
15
  $ bundle
16
16
 
17
- Or install it yourself as:
18
-
19
- $ gem install auto_breadcrumbs
20
-
21
- ### Installing locales
22
-
23
- To install locale file run:
17
+ To generate locale file run:
24
18
 
25
19
  $ rails g auto_breadcrumbs:install
26
20
 
@@ -31,7 +25,6 @@ To install locale file run:
31
25
  ```ruby
32
26
  class UsersController < ApplicationController
33
27
  include AutoBreadcrumbs
34
-
35
28
  ...
36
29
  end
37
30
  ```
@@ -40,7 +33,7 @@ end
40
33
 
41
34
  ```yml
42
35
  en:
43
- breadcrumbs:
36
+ auto_breadcrumbs:
44
37
  root: 'Home'
45
38
  actions:
46
39
  new: 'New'
@@ -62,9 +55,11 @@ en:
62
55
  </body>
63
56
  ```
64
57
 
58
+ For example, if you go to `/users/1/edit` it will show breadcrums like `Home / Users / Settings`.
59
+
65
60
  ## Customization
66
61
 
67
- For more information about breadcrumbs' customization visit [breadcrumbs_on_rails](https://github.com/weppos/breadcrumbs_on_rails).
62
+ For more information about customization of breadcrumbs visit [breadcrumbs_on_rails](https://github.com/weppos/breadcrumbs_on_rails).
68
63
 
69
64
  ## Contributing
70
65
 
@@ -73,8 +68,3 @@ For more information about breadcrumbs' customization visit [breadcrumbs_on_rail
73
68
  3. Commit your changes (`git commit -am 'Add some feature'`)
74
69
  4. Push to the branch (`git push origin my-new-feature`)
75
70
  5. Create new Pull Request
76
-
77
- ## TODO
78
-
79
- * Add tests
80
- * Add supporting of nested resources
@@ -19,4 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'breadcrumbs_on_rails'
22
+
23
+ spec.add_development_dependency 'activemodel'
24
+
25
+ spec.add_development_dependency 'rspec-rails'
26
+ spec.add_development_dependency 'capybara'
27
+ spec.add_development_dependency 'poltergeist'
22
28
  end
@@ -1,5 +1,5 @@
1
1
  en:
2
- breadcrumbs:
2
+ auto_breadcrumbs:
3
3
  root: 'Home'
4
4
  actions:
5
5
  new: 'New'
@@ -1,3 +1,5 @@
1
+ require 'breadcrumbs_on_rails'
2
+
1
3
  module AutoBreadcrumbs
2
4
  module Controller
3
5
  extend ActiveSupport::Concern
@@ -9,26 +11,23 @@ module AutoBreadcrumbs
9
11
  private
10
12
 
11
13
  def add_breadcrumb_on_action(options = {})
12
- add_breadcrumb I18n.t('breadcrumbs.root'), :root_path
13
-
14
- if request.path != root_path
15
- if controllers_index_path && params[:action] == 'index'
16
- add_breadcrumb index_translation, controllers_index_path
17
- else
18
- add_breadcrumb action_translation
19
- end
14
+ add_breadcrumb breadcrumbs_t('root'), :root_path
15
+
16
+ unless request.path == root_path
17
+ add_breadcrumb(index_translation, controllers_index_path) if controllers_index_path
18
+ add_breadcrumb(action_translation) unless params[:action] == 'index'
20
19
  end
21
20
  end
22
21
 
23
22
  def index_translation
24
- I18n.t("breadcrumbs.controllers.#{ params[:controller] }.index")
23
+ breadcrumbs_t("controllers.#{ params[:controller] }.index")
25
24
  end
26
25
 
27
26
  def action_translation
28
27
  begin
29
- I18n.t!("breadcrumbs.controllers.#{ params[:controller] }.#{ breadcrumbs_action_name }")
28
+ breadcrumbs_t!("controllers.#{ params[:controller] }.#{ breadcrumbs_action_name }")
30
29
  rescue I18n::MissingTranslationData
31
- I18n.t("breadcrumbs.actions.#{ breadcrumbs_action_name }")
30
+ breadcrumbs_t("actions.#{ breadcrumbs_action_name }")
32
31
  end
33
32
  end
34
33
 
@@ -46,5 +45,13 @@ module AutoBreadcrumbs
46
45
  params[:action]
47
46
  end
48
47
  end
48
+
49
+ def breadcrumbs_t(path)
50
+ I18n.t('auto_breadcrumbs.' << path)
51
+ end
52
+
53
+ def breadcrumbs_t!(path)
54
+ I18n.t!('auto_breadcrumbs.' << path)
55
+ end
49
56
  end
50
57
  end
@@ -1,3 +1,3 @@
1
1
  module AutoBreadcrumbs
2
- VERSION = '0.0.2'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ include AutoBreadcrumbs
3
+
4
+ before_filter -> { render 'shared/blank_page' }
5
+ end
@@ -0,0 +1,7 @@
1
+ class CitiesController < ApplicationController
2
+ def edit
3
+ end
4
+
5
+ def show
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ class UsersController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def show
6
+ end
7
+
8
+ def edit
9
+ end
10
+
11
+ def dup
12
+ end
13
+
14
+ def sync
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= render_breadcrumbs separator: '/' %>
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
File without changes
@@ -0,0 +1,21 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+
7
+ module Dummy
8
+ class Application < Rails::Application
9
+ # Settings in config/environments/* take precedence over those specified here.
10
+ # Application configuration should go into files in config/initializers
11
+ # -- all .rb files in that directory are automatically loaded.
12
+
13
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
14
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
15
+ # config.time_zone = 'Central Time (US & Canada)'
16
+
17
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
18
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
19
+ # config.i18n.default_locale = :de
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +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
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,29 @@
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
+ # Do not eager load code on boot.
10
+ config.eager_load = false
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
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end
@@ -0,0 +1,80 @@
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
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation can not be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Disable automatic flushing of the log to improve performance.
76
+ # config.autoflush_log = false
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+ end
@@ -0,0 +1,36 @@
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
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = "public, max-age=3600"
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = true
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ # config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+ end
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ Dummy::Application.config.secret_key_base = '72b84484d1fdd5faa3ff6b09182a13b26010880c681bd3f6c575f61cdca53640d08c344fd97cb2e058ff713264ce780439d6fa3bd0ada716309de98520efbccd'
@@ -0,0 +1,16 @@
1
+ en:
2
+ auto_breadcrumbs:
3
+ root: 'Home'
4
+ actions:
5
+ new: 'New'
6
+ show: 'Show'
7
+ edit: 'Edit'
8
+ controllers:
9
+ users:
10
+ index: 'Users'
11
+ edit: 'Settings'
12
+ sync: 'Synchronization'
13
+ dup: 'Duplication'
14
+ cities:
15
+ index: 'Cities / Towns'
16
+ show: 'Browse'
@@ -0,0 +1,10 @@
1
+ Dummy::Application.routes.draw do
2
+ root to: 'users#index'
3
+
4
+ resources :users, only: [:index, :show, :edit] do
5
+ get :sync, on: :collection
6
+ get :dup, on: :member
7
+ end
8
+
9
+ resources :cities, only: [:edit, :show]
10
+ 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 Rails.application
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,11 @@
1
+ class BreadcrumbPage < Struct.new(:paths)
2
+ include Capybara::DSL
3
+
4
+ def visit_page(path)
5
+ visit paths[path]
6
+ end
7
+
8
+ def breadcrumbs
9
+ find('body').text.split('/')
10
+ end
11
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+ require 'features/pages/breadcrumb_page'
3
+
4
+ feature 'Rendering breadcrumbs' do
5
+ let(:locale) { YAML.load(File.open(Rails.root.join('config/locales/auto_breadcrumbs.en.yml')))['en']['auto_breadcrumbs'] }
6
+
7
+ # Root page -------------------------------------------------------------------------------------
8
+
9
+ let(:root_page) { BreadcrumbPage.new(index: root_path) }
10
+ let(:root_breadcrumbs) { [locale['root']] }
11
+
12
+ # City page -------------------------------------------------------------------------------------
13
+
14
+ let(:city_page) {
15
+ BreadcrumbPage.new edit: edit_city_path('id'),
16
+ show: city_path('id')
17
+ }
18
+ let(:city_edit_breadcrumbs) { root_breadcrumbs + [locale['actions']['edit']] }
19
+ let(:city_show_breadcrumbs) { root_breadcrumbs + [locale['controllers']['cities']['show']] }
20
+
21
+ # User page -------------------------------------------------------------------------------------
22
+
23
+ let(:user_page) {
24
+ BreadcrumbPage.new index: users_path,
25
+ show: user_path('id'),
26
+ edit: edit_user_path('id'),
27
+ dup: dup_user_path('id'),
28
+ sync: sync_users_path
29
+ }
30
+ let(:user_index_breadcrumbs) { root_breadcrumbs + [locale['controllers']['users']['index']] }
31
+ let(:user_show_breadcrumbs) { user_index_breadcrumbs + [locale['actions']['show']] }
32
+ let(:user_edit_breadcrumbs) { user_index_breadcrumbs + [locale['controllers']['users']['edit']] }
33
+ let(:user_dup_breadcrumbs) { user_index_breadcrumbs + [locale['controllers']['users']['dup']] }
34
+ let(:user_sync_breadcrumbs) { user_index_breadcrumbs + [locale['controllers']['users']['sync']] }
35
+
36
+ # -----------------------------------------------------------------------------------------------
37
+
38
+ scenario 'on root page' do
39
+ root_page.visit_page(:index)
40
+ expect(root_page.breadcrumbs).to eq(root_breadcrumbs)
41
+ end
42
+
43
+ scenario 'when resource without index action' do
44
+ city_page.visit_page(:edit)
45
+ expect(city_page.breadcrumbs).to eq(city_edit_breadcrumbs)
46
+
47
+ city_page.visit_page(:show)
48
+ expect(city_page.breadcrumbs).to eq(city_show_breadcrumbs)
49
+ end
50
+
51
+ scenario 'when resource with index action' do
52
+ user_page.visit_page(:index)
53
+ expect(user_page.breadcrumbs).to eq(user_index_breadcrumbs)
54
+
55
+ user_page.visit_page(:show)
56
+ expect(user_page.breadcrumbs).to eq(user_show_breadcrumbs)
57
+
58
+ user_page.visit_page(:edit)
59
+ expect(user_page.breadcrumbs).to eq(user_edit_breadcrumbs)
60
+
61
+ user_page.visit_page(:dup)
62
+ expect(user_page.breadcrumbs).to eq(user_dup_breadcrumbs)
63
+
64
+ user_page.visit_page(:sync)
65
+ expect(user_page.breadcrumbs).to eq(user_sync_breadcrumbs)
66
+ end
67
+ end
@@ -0,0 +1,10 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+
5
+ require 'rspec/rails'
6
+ require 'capybara/rspec'
7
+ require 'capybara/rails'
8
+ require 'capybara/poltergeist'
9
+
10
+ Capybara.javascript_driver = :poltergeist
metadata CHANGED
@@ -1,27 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_breadcrumbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-18 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: breadcrumbs_on_rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: poltergeist
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
25
81
  - !ruby/object:Gem::Version
26
82
  version: '0'
27
83
  description: Automatically add breadcrumbs to each page by using locales
@@ -31,6 +87,8 @@ executables: []
31
87
  extensions: []
32
88
  extra_rdoc_files: []
33
89
  files:
90
+ - .rspec
91
+ - .travis.yml
34
92
  - Gemfile
35
93
  - LICENSE.txt
36
94
  - README.md
@@ -41,6 +99,29 @@ files:
41
99
  - lib/auto_breadcrumbs/controller.rb
42
100
  - lib/auto_breadcrumbs/version.rb
43
101
  - lib/generators/auto_breadcrumbs/install_generator.rb
102
+ - spec/dummy/app/controllers/application_controller.rb
103
+ - spec/dummy/app/controllers/cities_controller.rb
104
+ - spec/dummy/app/controllers/users_controller.rb
105
+ - spec/dummy/app/views/layouts/application.html.erb
106
+ - spec/dummy/app/views/shared/blank_page.html.erb
107
+ - spec/dummy/config.ru
108
+ - spec/dummy/config/application.rb
109
+ - spec/dummy/config/boot.rb
110
+ - spec/dummy/config/database.yml
111
+ - spec/dummy/config/environment.rb
112
+ - spec/dummy/config/environments/development.rb
113
+ - spec/dummy/config/environments/production.rb
114
+ - spec/dummy/config/environments/test.rb
115
+ - spec/dummy/config/initializers/secret_token.rb
116
+ - spec/dummy/config/locales/auto_breadcrumbs.en.yml
117
+ - spec/dummy/config/routes.rb
118
+ - spec/dummy/public/404.html
119
+ - spec/dummy/public/422.html
120
+ - spec/dummy/public/500.html
121
+ - spec/dummy/public/favicon.ico
122
+ - spec/features/pages/breadcrumb_page.rb
123
+ - spec/features/rendering_breadcrumbs_spec.rb
124
+ - spec/spec_helper.rb
44
125
  homepage: https://github.com/exAspArk/auto_breadcrumbs
45
126
  licenses:
46
127
  - MIT
@@ -51,18 +132,42 @@ require_paths:
51
132
  - lib
52
133
  required_ruby_version: !ruby/object:Gem::Requirement
53
134
  requirements:
54
- - - '>='
135
+ - - ! '>='
55
136
  - !ruby/object:Gem::Version
56
137
  version: '0'
57
138
  required_rubygems_version: !ruby/object:Gem::Requirement
58
139
  requirements:
59
- - - '>='
140
+ - - ! '>='
60
141
  - !ruby/object:Gem::Version
61
142
  version: '0'
62
143
  requirements: []
63
144
  rubyforge_project:
64
- rubygems_version: 2.0.3
145
+ rubygems_version: 2.1.5
65
146
  signing_key:
66
147
  specification_version: 4
67
148
  summary: Automatically adding breadcrumbs by using locales
68
- test_files: []
149
+ test_files:
150
+ - spec/dummy/app/controllers/application_controller.rb
151
+ - spec/dummy/app/controllers/cities_controller.rb
152
+ - spec/dummy/app/controllers/users_controller.rb
153
+ - spec/dummy/app/views/layouts/application.html.erb
154
+ - spec/dummy/app/views/shared/blank_page.html.erb
155
+ - spec/dummy/config.ru
156
+ - spec/dummy/config/application.rb
157
+ - spec/dummy/config/boot.rb
158
+ - spec/dummy/config/database.yml
159
+ - spec/dummy/config/environment.rb
160
+ - spec/dummy/config/environments/development.rb
161
+ - spec/dummy/config/environments/production.rb
162
+ - spec/dummy/config/environments/test.rb
163
+ - spec/dummy/config/initializers/secret_token.rb
164
+ - spec/dummy/config/locales/auto_breadcrumbs.en.yml
165
+ - spec/dummy/config/routes.rb
166
+ - spec/dummy/public/404.html
167
+ - spec/dummy/public/422.html
168
+ - spec/dummy/public/500.html
169
+ - spec/dummy/public/favicon.ico
170
+ - spec/features/pages/breadcrumb_page.rb
171
+ - spec/features/rendering_breadcrumbs_spec.rb
172
+ - spec/spec_helper.rb
173
+ has_rdoc: