buoys 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e78176edf374e239e8edc82b58967bd7c8af0db
4
- data.tar.gz: 5bc190247b5979b6ceb386efa33e95cbf0b5f963
3
+ metadata.gz: 97ccbfd2f85553dc5bda98c988308808b62c822b
4
+ data.tar.gz: 23c895177daf452393d88e549d25c1c3cdf67d92
5
5
  SHA512:
6
- metadata.gz: 980a48fac48ff04a5926fc8fe7092f99569e84004159114d039c7b65622f59c47fc046ea4ae7ded09c47676781133d08b2c2aceb7d7e29ecffa04a0c994ffa03
7
- data.tar.gz: 86540406c985a7c063d056a78a9af5b566c74c7cd0bce44c3296fa963251a4d6974ca1e55d2ccb7977932f00d1c035d1a73507758f598a6cf333b0144862fdaf
6
+ metadata.gz: a677c4c0d1ca840b5893674efa83f4b66af0ccd8f178e353c9a017f91a82e3a523a4296282477f7dc1cefdd20267ba8c5d72e5521873fc6d106f2e04b6fe9b12
7
+ data.tar.gz: f6682ff57a57fce2d8b716185c3889003477e82718446419f8d7083cb6347f23dd3fedfc16cd221c978749644498d1dc67795d58d55b2ead86b9082edf558a2d
data/lib/buoys/buoy.rb CHANGED
@@ -34,7 +34,7 @@ module Buoys
34
34
  end
35
35
 
36
36
  def pre_buoy(key, *args)
37
- @previous = Buoys::Buoy.new(context, key, args)
37
+ @previous = Buoys::Buoy.new(context, key, *args)
38
38
  end
39
39
  alias parent pre_buoy
40
40
 
data/lib/buoys/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Buoys
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -71,7 +71,7 @@ class BuoysHelerTest < ActionView::TestCase
71
71
  <span>&gt;</span>
72
72
  </li>
73
73
  <li>
74
- <a class="active" href="http://example.com/books/1/authors/2">
74
+ <a class="active" href="http://example.com/books/1/authors/2/edit">
75
75
  <span>edit-1-2</span>
76
76
  </a>
77
77
  </li>
@@ -81,6 +81,32 @@ class BuoysHelerTest < ActionView::TestCase
81
81
  assert_dom_equal expected_html, html
82
82
  end
83
83
 
84
+ test '.buoy (use polymorphic routes)' do
85
+ user = User.create(name: 'test user')
86
+ item = Item.create(name: 'test item')
87
+
88
+ breadcrumb :edit_user_item, [user, item]
89
+ html = render('breadcrumbs/buoys').gsub(/[[:space:]]{2,}|\n/, '')
90
+ expected_html =
91
+ %(
92
+ <ul>
93
+ <li>
94
+ <a class="hover" href="/users/#{user.id}/items/#{item.id}">
95
+ <span>show user item</span>
96
+ </a>
97
+ <span>&gt;</span>
98
+ </li>
99
+ <li>
100
+ <a class="active" href="/users/#{user.id}/items/#{item.id}/edit">
101
+ <span>edit user item</span>
102
+ </a>
103
+ </li>
104
+ </ul>
105
+ ).gsub(/[[:space:]]{2,}|\n/, '')
106
+
107
+ assert_dom_equal expected_html, html
108
+ end
109
+
84
110
  test ".buoy (has configuration options in link's arguments)" do
85
111
  breadcrumb :show_books, 1
86
112
  html = render('breadcrumbs/buoys').gsub(/[[:space:]]{2,}|\n/, '')
@@ -0,0 +1,6 @@
1
+ class ItemsController < ApplicationController
2
+ def show
3
+ end
4
+ def edit
5
+ end
6
+ end
@@ -0,0 +1,2 @@
1
+ class Item < ActiveRecord::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class User < ActiveRecord::Base
2
+ end
@@ -21,6 +21,8 @@ module Dummy
21
21
  config.i18n.default_locale = :en
22
22
 
23
23
  # Do not swallow errors in after_commit/after_rollback callbacks.
24
- config.active_record.raise_in_transactional_callbacks = true
24
+ if Gem::Version.new(Rails.version) >= Gem::Version.new("4.2.0")
25
+ config.active_record.raise_in_transactional_callbacks = true
26
+ end
25
27
  end
26
28
  end
@@ -13,5 +13,14 @@ end
13
13
 
14
14
  buoy :edit_book_author do |book_id, author_id|
15
15
  parent :books
16
- link "edit-#{book_id}-#{author_id}", "http://example.com/books/#{book_id}/authors/#{author_id}", link_current: true
16
+ link "edit-#{book_id}-#{author_id}", "http://example.com/books/#{book_id}/authors/#{author_id}/edit", link_current: true
17
+ end
18
+
19
+ buoy :show_user_item do |user, item|
20
+ link :show_user_item, [user, item]
21
+ end
22
+
23
+ buoy :edit_user_item do |user, item|
24
+ pre_buoy :show_user_item, [user, item]
25
+ link :edit_user_item, [:edit, user, item], link_current: true
17
26
  end
@@ -25,3 +25,5 @@ en:
25
25
  buoys:
26
26
  breadcrumbs:
27
27
  account: 'Account'
28
+ show_user_item: 'show user item'
29
+ edit_user_item: 'edit user item'
@@ -1,4 +1,8 @@
1
1
  Rails.application.routes.draw do
2
- get 'about' => 'dummy/dummy', as: :about
3
- get 'about/history' => 'dummy/dummy', as: :history
2
+ get 'about' => 'dummy#dummy', as: :about
3
+ get 'about/history' => 'dummy#dummy', as: :history
4
+
5
+ resources :users, only: [] do
6
+ resources :items, only: %i(show edit)
7
+ end
4
8
  end
Binary file
@@ -0,0 +1,9 @@
1
+ class CreateItems < ActiveRecord::Migration
2
+ def change
3
+ create_table :items do |t|
4
+ t.string :name
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :name
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -11,6 +11,18 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 0) do
14
+ ActiveRecord::Schema.define(version: 20160602144324) do
15
+
16
+ create_table "items", force: :cascade do |t|
17
+ t.string "name"
18
+ t.datetime "created_at", null: false
19
+ t.datetime "updated_at", null: false
20
+ end
21
+
22
+ create_table "users", force: :cascade do |t|
23
+ t.string "name"
24
+ t.datetime "created_at", null: false
25
+ t.datetime "updated_at", null: false
26
+ end
15
27
 
16
28
  end
Binary file
@@ -0,0 +1,10 @@
1
+  (4.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2
+  (0.1ms) select sqlite_version(*)
3
+  (4.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
4
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
5
+  (5.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
6
+  (0.1ms) select sqlite_version(*)
7
+  (4.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
8
+  (0.1ms) SELECT version FROM "schema_migrations"
9
+  (3.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
10
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1