rails_core_extensions 0.7.1 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +59 -0
- data/.github/workflows/ruby.yml +19 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +23 -0
- data/README.md +20 -8
- data/gemfiles/rails60.gemfile +6 -0
- data/gemfiles/rails61.gemfile +6 -0
- data/lib/rails_core_extensions.rb +9 -13
- data/lib/rails_core_extensions/action_view_extensions.rb +0 -36
- data/lib/rails_core_extensions/active_record_extensions.rb +1 -68
- data/lib/rails_core_extensions/sortable.rb +2 -2
- data/lib/rails_core_extensions/translations.rb +1 -1
- data/lib/rails_core_extensions/version.rb +1 -1
- data/rails_core_extensions.gemspec +3 -7
- data/spec/action_controller_sortable_spec.rb +1 -1
- data/spec/active_record_extensions_spec.rb +0 -54
- data/spec/support/coverage_loader.rb +2 -1
- metadata +12 -60
- data/.travis.yml +0 -19
- data/gemfiles/rails5.gemfile +0 -6
- data/gemfiles/rails6.gemfile +0 -6
- data/lib/rails_core_extensions/action_view_currency_extensions.rb +0 -26
- data/lib/rails_core_extensions/active_record_cache_all_attributes.rb +0 -39
- data/lib/rails_core_extensions/breadcrumb.rb +0 -170
- data/lib/rails_core_extensions/caches_action_without_host.rb +0 -17
- data/spec/breadcrumb_spec.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08b7b45e052b4fd8509ad421e7781577474c4313b6a9168cd26714fb2ec147dd'
|
4
|
+
data.tar.gz: 59a25f7d6ae73d5392e06e4dfa63950d9314b235c02c13142fa7926e84c5c233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d6deae57b5db102c8de52810703c0a61445c5b7f19f316f3351cabf247836e9e3a614bd36ed3fc0e2eb0443c8e52231ee65164a0ba90e9573620814530d2729
|
7
|
+
data.tar.gz: '079894f7e26646ae5eef57d863b354e0e2eddae4d4b68f495bb95bf18c75ecbee18638a793f0f169089941d8e31efc4cf1bc6ab178391ca107f35dc4f06a6161'
|
@@ -0,0 +1,59 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- "v*"
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
name: Build
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- name: Checkout
|
14
|
+
uses: actions/checkout@v2
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
bundler-cache: true
|
18
|
+
- run: bundle exec rake
|
19
|
+
|
20
|
+
release:
|
21
|
+
needs: build
|
22
|
+
name: Release
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
steps:
|
25
|
+
- name: Checkout
|
26
|
+
uses: actions/checkout@v2
|
27
|
+
|
28
|
+
- name: Generate Changelog
|
29
|
+
run: |
|
30
|
+
# Get version from github ref (remove 'refs/tags/' and prefix 'v')
|
31
|
+
version="${GITHUB_REF#refs/tags/v}"
|
32
|
+
npx changelog-parser CHANGELOG.md | jq -cr ".versions | .[] | select(.version == \"$version\") | .body" > ${{ github.workflow }}-CHANGELOG.txt
|
33
|
+
|
34
|
+
- name: Release
|
35
|
+
uses: softprops/action-gh-release@v1
|
36
|
+
with:
|
37
|
+
body_path: ${{ github.workflow }}-CHANGELOG.txt
|
38
|
+
env:
|
39
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
40
|
+
|
41
|
+
publish:
|
42
|
+
needs: [build, release]
|
43
|
+
name: Publish
|
44
|
+
runs-on: ubuntu-latest
|
45
|
+
|
46
|
+
steps:
|
47
|
+
- uses: actions/checkout@v2
|
48
|
+
- uses: ruby/setup-ruby@v1
|
49
|
+
|
50
|
+
- name: Publish to RubyGems
|
51
|
+
run: |
|
52
|
+
mkdir -p $HOME/.gem
|
53
|
+
touch $HOME/.gem/credentials
|
54
|
+
chmod 0600 $HOME/.gem/credentials
|
55
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
56
|
+
gem build *.gemspec
|
57
|
+
gem push *.gem
|
58
|
+
env:
|
59
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: Build and Test
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
gemfile: [rails60, rails61]
|
9
|
+
ruby: ["2.6", "2.7", "3.0"]
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
env:
|
12
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
bundler-cache: true
|
19
|
+
- run: bundle exec rake
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.11.1
|
4
|
+
|
5
|
+
* [TT-8608] Fix broken rake command in the gem publish stage
|
6
|
+
|
7
|
+
## 0.11.0
|
8
|
+
|
9
|
+
* [TT-8608] Switch from travis to gihthub actions
|
10
|
+
* [TT-8608] Add support for Rails 6.1 / Ruby 3
|
11
|
+
|
12
|
+
## 0.10.0
|
13
|
+
|
14
|
+
* [TT-8507] Sortable will now fire callbacks to ensure we audit these changes
|
15
|
+
|
16
|
+
## 0.9.0
|
17
|
+
|
18
|
+
* [TT-6727] Fix usage of symbolize_keys in sortable
|
19
|
+
|
20
|
+
## 0.8.0
|
21
|
+
|
22
|
+
* [TT-6539] Remove cache_all_attributes and other unused methods
|
23
|
+
* [TT-5384] Remove validates_presence_of_parent method (Use rails optional flag instead)
|
24
|
+
* [TT-6293] Drop breadcrumbs / cache without host and some unused view helpers
|
25
|
+
|
3
26
|
## 0.7.1
|
4
27
|
|
5
28
|
* [TT-5745] Fix passing of symbol to liquid template parse
|
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
Rails Core Extensions
|
2
|
-
====================
|
1
|
+
# Rails Core Extensions
|
3
2
|
|
4
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/sealink/rails_core_extensions/workflows/Build/badge.svg?branch=master)](https://github.com/sealink/rails_core_extensions/actions)
|
5
4
|
[![Coverage Status](https://coveralls.io/repos/sealink/rails_core_extensions/badge.png)](https://coveralls.io/r/sealink/rails_core_extensions)
|
6
|
-
[![Dependency Status](https://gemnasium.com/sealink/rails_core_extensions.png?travis)](https://gemnasium.com/sealink/rails_core_extensions)
|
7
5
|
[![Code Climate](https://codeclimate.com/github/sealink/rails_core_extensions.png)](https://codeclimate.com/github/sealink/rails_core_extensions)
|
8
6
|
|
9
7
|
# DESCRIPTION
|
@@ -30,7 +28,7 @@ end
|
|
30
28
|
|
31
29
|
config/routes.rb
|
32
30
|
|
33
|
-
In Rails
|
31
|
+
In Rails 6:
|
34
32
|
resources :types do
|
35
33
|
collection
|
36
34
|
post :sort
|
@@ -42,18 +40,32 @@ You need to submit a collection of objects named the same as the controller.
|
|
42
40
|
|
43
41
|
e.g. for the above the params should be:
|
44
42
|
|
43
|
+
```ruby
|
45
44
|
types_body[]=1
|
46
45
|
types_body[]=3
|
47
|
-
|
46
|
+
```
|
48
47
|
|
49
48
|
Where the value is the id, and the position of submission is the new order, e.g.
|
50
49
|
In the above, the item of id 3 will be updated to position 2
|
51
50
|
|
52
51
|
If you have scoped sorts, e.g. sorts within categories you also need to pass in 2 params:
|
53
|
-
|
54
|
-
|
52
|
+
|
53
|
+
- scope (e.g. category_id)
|
54
|
+
- a variable by that name, e.g. category_id
|
55
55
|
|
56
56
|
So in the above if you want to upgrade category_id 6, you could submit
|
57
57
|
scope=category_id&category_id=6
|
58
58
|
|
59
59
|
along with type_body[]=7.. for all the types in category 6
|
60
|
+
|
61
|
+
# RELEASE
|
62
|
+
|
63
|
+
To publish a new version of this gem the following steps must be taken.
|
64
|
+
|
65
|
+
* Update the version in the following files
|
66
|
+
```
|
67
|
+
CHANGELOG.md
|
68
|
+
lib/rails_core_extensions/version.rb
|
69
|
+
````
|
70
|
+
* Create a tag using the format v0.1.0
|
71
|
+
* Follow build progress in GitHub actions
|
@@ -1,9 +1,5 @@
|
|
1
1
|
module RailsCoreExtensions
|
2
2
|
require 'rails_core_extensions/sortable'
|
3
|
-
require 'rails_core_extensions/action_view_currency_extensions'
|
4
|
-
require 'rails_core_extensions/action_view_has_many_extensions'
|
5
|
-
require 'rails_core_extensions/action_view_extensions'
|
6
|
-
require 'rails_core_extensions/breadcrumb'
|
7
3
|
require 'rails_core_extensions/position_initializer'
|
8
4
|
require 'rails_core_extensions/time_with_zone'
|
9
5
|
require 'rails_core_extensions/transfer_records'
|
@@ -13,32 +9,32 @@ module RailsCoreExtensions
|
|
13
9
|
require 'rails_core_extensions/railtie' if defined?(Rails)
|
14
10
|
|
15
11
|
if defined? ActionController
|
16
|
-
require 'rails_core_extensions/caches_action_without_host'
|
17
12
|
require 'rails_core_extensions/activatable'
|
18
13
|
require 'rails_core_extensions/action_controller_sortable'
|
19
14
|
|
20
|
-
ActionController::Base.send(:include, CachesActionWithoutHost)
|
21
15
|
ActionController::Base.send(:include, Activatable)
|
22
16
|
ActionController::Base.send(:include, ActionControllerSortable)
|
23
17
|
end
|
24
18
|
|
19
|
+
if defined? ActionView
|
20
|
+
require 'rails_core_extensions/action_view_extensions'
|
21
|
+
require 'rails_core_extensions/action_view_has_many_extensions'
|
22
|
+
|
23
|
+
ActionView::Base.send(:include, RailsCoreExtensions::ActionViewExtensions)
|
24
|
+
end
|
25
|
+
|
25
26
|
if defined? ActiveRecord
|
26
27
|
require 'rails_core_extensions/active_record_cloning'
|
27
|
-
require 'rails_core_extensions/active_record_cache_all_attributes'
|
28
28
|
require 'rails_core_extensions/active_record_extensions'
|
29
29
|
require 'rails_core_extensions/active_record_liquid_extensions'
|
30
30
|
require 'rails_core_extensions/translations'
|
31
|
+
require 'rails_core_extensions/active_model_extensions'
|
31
32
|
|
32
33
|
ActiveRecord::Base.send(:include, ActiveRecordCloning)
|
33
34
|
ActiveRecord::Base.send(:include, ActiveRecordExtensions)
|
34
35
|
ActiveRecord::Base.send(:include, RailsCoreExtensions::ActiveRecordLiquidExtensions)
|
35
36
|
ActiveRecord::Base.send(:include, ActiveRecordExtensions::InstanceMethods)
|
36
37
|
ActiveRecord::Base.send(:include, RailsCoreExtensions::Translations)
|
37
|
-
|
38
|
-
if ActiveRecord::VERSION::MAJOR >= 3
|
39
|
-
require 'rails_core_extensions/active_model_extensions'
|
40
|
-
ActiveRecord::Base.send(:include, ActiveModelExtensions::Validations)
|
41
|
-
end
|
38
|
+
ActiveRecord::Base.send(:include, ActiveModelExtensions::Validations)
|
42
39
|
end
|
43
40
|
end
|
44
|
-
|
@@ -4,25 +4,6 @@ module RailsCoreExtensions
|
|
4
4
|
super(h(content)).html_safe
|
5
5
|
end
|
6
6
|
|
7
|
-
# Will recursively parse a Hash and any sub hashes to be normal hashes
|
8
|
-
# This is useful when exporting hashes to non ruby systems, which don't understand HashWithIndifferentAccess
|
9
|
-
def hashify(element)
|
10
|
-
if element.is_a? Hash
|
11
|
-
element = element.to_hash if element.is_a?(HashWithIndifferentAccess)
|
12
|
-
element.each_pair do |key, value|
|
13
|
-
element[key] = hashify(value)
|
14
|
-
end
|
15
|
-
else
|
16
|
-
# Must hashify enumerables encase their sub items are hashes
|
17
|
-
# Can't enumerate through string as it returns strings, which are also enumerable (stack level too deep)
|
18
|
-
if element.respond_to?(:each) && !element.is_a?(String)
|
19
|
-
element.map{ |sub| hashify(sub) }
|
20
|
-
else
|
21
|
-
element
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
7
|
# Generates a tooltip with given text
|
27
8
|
# text is textilized before display
|
28
9
|
def tooltip(hover_element_id, text, title='')
|
@@ -34,21 +15,6 @@ module RailsCoreExtensions
|
|
34
15
|
"</script>"
|
35
16
|
end
|
36
17
|
|
37
|
-
def expandable_list_for(objects, show = 4)
|
38
|
-
first, others = objects[0..(show-1)], objects[show..(objects.size-1)]
|
39
|
-
first.each do |o|
|
40
|
-
yield o
|
41
|
-
end
|
42
|
-
if others
|
43
|
-
content_tag 'div', :id => 'others', :style => 'display: none' do
|
44
|
-
others.each do |o|
|
45
|
-
yield o
|
46
|
-
end
|
47
|
-
end
|
48
|
-
"#{others.size} Others - ".html_safe + link_to_function("Show/Hide", "$('others').toggle()")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
18
|
def boolean_select_tag(name, *args)
|
53
19
|
options = args.extract_options!
|
54
20
|
options ||= {}
|
@@ -58,5 +24,3 @@ module RailsCoreExtensions
|
|
58
24
|
end
|
59
25
|
end
|
60
26
|
end
|
61
|
-
|
62
|
-
ActionView::Base.send(:include, RailsCoreExtensions::ActionViewExtensions) if defined?(ActionView::Base)
|
@@ -11,37 +11,6 @@ module ActiveRecordExtensions
|
|
11
11
|
establish_connection("#{key}_#{Rails.env}")
|
12
12
|
end
|
13
13
|
|
14
|
-
def cache_all_attributes(options = {})
|
15
|
-
method = options[:by] || 'id'
|
16
|
-
class_eval <<-CACHE
|
17
|
-
after_save :clear_attribute_cache
|
18
|
-
after_destroy :clear_attribute_cache
|
19
|
-
cattr_accessor :cache_attributes_by
|
20
|
-
self.cache_attributes_by = '#{method}'
|
21
|
-
CACHE
|
22
|
-
extend ActiveRecordCacheAllAttributes::ClassMethods
|
23
|
-
include ActiveRecordCacheAllAttributes::InstanceMethods
|
24
|
-
end
|
25
|
-
|
26
|
-
# Create a new object from the attributes passed in
|
27
|
-
# OR update an existing
|
28
|
-
#
|
29
|
-
# If an :id attribute is present it will assume it's an existing record, and needs update
|
30
|
-
def new_or_update!(hash={}, options = {:hard_update => true})
|
31
|
-
hash.symbolize_keys!
|
32
|
-
if hash[:id].blank?
|
33
|
-
self.new(hash)
|
34
|
-
else
|
35
|
-
rec = self.find(hash[:id])
|
36
|
-
if options[:hard_update]
|
37
|
-
rec.update_attributes!(hash.except(:id))
|
38
|
-
else
|
39
|
-
rec.update_attributes(hash.except(:id))
|
40
|
-
end
|
41
|
-
rec
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
14
|
def enum_int(field, values, options = {})
|
46
15
|
const_set("#{field.to_s.upcase}_OPTIONS", values)
|
47
16
|
|
@@ -101,49 +70,13 @@ module ActiveRecordExtensions
|
|
101
70
|
reload
|
102
71
|
#{collection}.sort_by(&:position).each_with_index do |o, index|
|
103
72
|
if o.position != (index + 1)
|
104
|
-
o.
|
73
|
+
o.update(:position, index + 1)
|
105
74
|
end
|
106
75
|
end
|
107
76
|
end
|
108
77
|
EVAL
|
109
78
|
end
|
110
79
|
end
|
111
|
-
|
112
|
-
# Validates presence of -- but works on parent within accepts_nested_attributes
|
113
|
-
#
|
114
|
-
def validates_presence_of_parent(foreign_key)
|
115
|
-
after_save do |record|
|
116
|
-
unless record.send(foreign_key)
|
117
|
-
record.errors.add_on_blank(foreign_key)
|
118
|
-
raise ActiveRecord::ActiveRecordError, record.errors.full_messages.to_sentence
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
# Run a block, being respectful of connection pools
|
124
|
-
#
|
125
|
-
# Useful for when you're not in the standard rails request process,
|
126
|
-
# since normally rails will take, then clear you're connection in the
|
127
|
-
# processing of the request.
|
128
|
-
#
|
129
|
-
# If you don't do this in, say, a command line task with threads, then
|
130
|
-
# you'll run out of connections after 5 x Threads are run simultaneously...
|
131
|
-
def with_connection_pooling
|
132
|
-
# Verify active connections and remove and disconnect connections
|
133
|
-
# associated with stale threads.
|
134
|
-
ActiveRecord::Base.verify_active_connections!
|
135
|
-
|
136
|
-
yield
|
137
|
-
|
138
|
-
# This code checks in the connection being used by the current thread back
|
139
|
-
# into the connection pool. It repeats this if you are using multiple
|
140
|
-
# connection pools. It will not disconnect the connection.
|
141
|
-
#
|
142
|
-
# Returns any connections in use by the current thread back to the pool,
|
143
|
-
# and also returns connections to the pool cached by threads that are no
|
144
|
-
# longer alive.
|
145
|
-
ActiveRecord::Base.clear_active_connections!
|
146
|
-
end
|
147
80
|
end
|
148
81
|
|
149
82
|
module InstanceMethods
|
@@ -8,7 +8,7 @@ module RailsCoreExtensions
|
|
8
8
|
# category_id (or whatever the name of scope is)
|
9
9
|
# model_1_body (or whatever id of scope id)
|
10
10
|
def initialize(params, controller_name)
|
11
|
-
@params = params.symbolize_keys
|
11
|
+
@params = params.permit!.to_h.symbolize_keys
|
12
12
|
@controller_name = controller_name
|
13
13
|
@klass = controller_name.classify.constantize
|
14
14
|
end
|
@@ -43,7 +43,7 @@ module RailsCoreExtensions
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def update(object, new_position)
|
46
|
-
@klass.
|
46
|
+
@klass.find(object.id).update(position: new_position)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
|
+
spec.required_ruby_version = '>= 2.6'
|
21
22
|
|
22
|
-
spec.add_dependency 'activerecord', ['>=
|
23
|
-
spec.add_dependency 'actionpack', ['>=
|
23
|
+
spec.add_dependency 'activerecord', ['>= 6.0.0']
|
24
|
+
spec.add_dependency 'actionpack', ['>= 6.0.0']
|
24
25
|
|
25
26
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
27
|
spec.add_development_dependency 'rake'
|
@@ -31,9 +32,4 @@ Gem::Specification.new do |spec|
|
|
31
32
|
spec.add_development_dependency 'coveralls'
|
32
33
|
spec.add_development_dependency 'rubocop'
|
33
34
|
spec.add_development_dependency 'sqlite3'
|
34
|
-
spec.add_development_dependency 'travis'
|
35
|
-
|
36
|
-
# breadcrumbs optional dependencies
|
37
|
-
spec.add_development_dependency 'make_resourceful'
|
38
|
-
spec.add_development_dependency 'inherited_resources'
|
39
35
|
end
|
@@ -26,7 +26,7 @@ describe RailsCoreExtensions::Sortable do
|
|
26
26
|
models.each(&:destroy)
|
27
27
|
end
|
28
28
|
|
29
|
-
subject { RailsCoreExtensions::Sortable.new(params, 'models') }
|
29
|
+
subject { RailsCoreExtensions::Sortable.new(ActionController::Parameters.new(params), 'models') }
|
30
30
|
|
31
31
|
RSpec.shared_examples 'unscoped' do
|
32
32
|
let(:scope) { Model.reorder(:position) }
|
@@ -68,25 +68,6 @@ describe 'enum_int' do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe "ActiveRecord::Base" do
|
72
|
-
let(:mock_model) { double }
|
73
|
-
let(:model_class) { Class.new(ActiveRecord::Base) }
|
74
|
-
before { stub_const 'Model', model_class }
|
75
|
-
|
76
|
-
it "should create a new record if new_or_update! is passed a hash without an :id" do
|
77
|
-
attributes = {:fake_column => 'nothing really'}
|
78
|
-
expect(Model).to receive(:new).with(attributes)
|
79
|
-
Model.new_or_update!(attributes)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should update record if new_or_update! is passed hash with :id" do
|
83
|
-
attributes = {:fake_column => 'nothing really', :id => 1}
|
84
|
-
expect(Model).to receive(:find) { mock_model }
|
85
|
-
expect(mock_model).to receive(:update_attributes!)
|
86
|
-
Model.new_or_update!(attributes)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
71
|
describe RailsCoreExtensions::ActionControllerSortable do
|
91
72
|
class NormalController < ActionController::Base
|
92
73
|
end
|
@@ -101,38 +82,3 @@ describe RailsCoreExtensions::ActionControllerSortable do
|
|
101
82
|
expect(SortableController.new.methods.map(&:to_sym)).to include(:sort)
|
102
83
|
end
|
103
84
|
end
|
104
|
-
|
105
|
-
describe ActiveRecordExtensions do
|
106
|
-
let(:model_class) {
|
107
|
-
Class.new(ActiveRecord::Base) do
|
108
|
-
cache_all_attributes :by => 'name'
|
109
|
-
end
|
110
|
-
}
|
111
|
-
let(:first) { Model.create!(:name => 'First') }
|
112
|
-
let(:second) { Model.create!(:name => 'Second') }
|
113
|
-
let(:expected) {
|
114
|
-
{
|
115
|
-
'First' => first.attributes,
|
116
|
-
'Second' => second.attributes
|
117
|
-
}
|
118
|
-
}
|
119
|
-
|
120
|
-
before do
|
121
|
-
connect_to_sqlite
|
122
|
-
stub_const 'Model', model_class
|
123
|
-
allow(Model).to receive(:cache) { ActiveSupport::Cache::MemoryStore.new }
|
124
|
-
allow(Model).to receive(:should_cache?) { true }
|
125
|
-
[first, second]
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'should cache all attributes' do
|
129
|
-
# Test underlying generate attributes hash method works
|
130
|
-
expect(Model.generate_attributes_hash).to eq expected
|
131
|
-
expect(Model.attribute_cache).to eq expected
|
132
|
-
|
133
|
-
# Test after save/destroy it updates
|
134
|
-
first.destroy
|
135
|
-
expect(Model.attribute_cache).to eq 'Second' => second.attributes
|
136
|
-
second.destroy # Clean up after
|
137
|
-
end
|
138
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_core_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 6.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 6.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: actionpack
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 6.0.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 6.0.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,48 +165,6 @@ dependencies:
|
|
165
165
|
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
|
-
- !ruby/object:Gem::Dependency
|
169
|
-
name: travis
|
170
|
-
requirement: !ruby/object:Gem::Requirement
|
171
|
-
requirements:
|
172
|
-
- - ">="
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
version: '0'
|
175
|
-
type: :development
|
176
|
-
prerelease: false
|
177
|
-
version_requirements: !ruby/object:Gem::Requirement
|
178
|
-
requirements:
|
179
|
-
- - ">="
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: '0'
|
182
|
-
- !ruby/object:Gem::Dependency
|
183
|
-
name: make_resourceful
|
184
|
-
requirement: !ruby/object:Gem::Requirement
|
185
|
-
requirements:
|
186
|
-
- - ">="
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
version: '0'
|
189
|
-
type: :development
|
190
|
-
prerelease: false
|
191
|
-
version_requirements: !ruby/object:Gem::Requirement
|
192
|
-
requirements:
|
193
|
-
- - ">="
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
version: '0'
|
196
|
-
- !ruby/object:Gem::Dependency
|
197
|
-
name: inherited_resources
|
198
|
-
requirement: !ruby/object:Gem::Requirement
|
199
|
-
requirements:
|
200
|
-
- - ">="
|
201
|
-
- !ruby/object:Gem::Version
|
202
|
-
version: '0'
|
203
|
-
type: :development
|
204
|
-
prerelease: false
|
205
|
-
version_requirements: !ruby/object:Gem::Requirement
|
206
|
-
requirements:
|
207
|
-
- - ">="
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
version: '0'
|
210
168
|
description: Set of extensions to core rails libraries.
|
211
169
|
email:
|
212
170
|
- support@travellink.com.au
|
@@ -214,33 +172,30 @@ executables: []
|
|
214
172
|
extensions: []
|
215
173
|
extra_rdoc_files: []
|
216
174
|
files:
|
175
|
+
- ".github/workflows/release.yml"
|
176
|
+
- ".github/workflows/ruby.yml"
|
217
177
|
- ".gitignore"
|
218
178
|
- ".hound.yml"
|
219
179
|
- ".rspec"
|
220
180
|
- ".ruby-style.yml"
|
221
181
|
- ".ruby-version"
|
222
|
-
- ".travis.yml"
|
223
182
|
- CHANGELOG.md
|
224
183
|
- Gemfile
|
225
184
|
- LICENSE.txt
|
226
185
|
- README.md
|
227
186
|
- Rakefile
|
228
|
-
- gemfiles/
|
229
|
-
- gemfiles/
|
187
|
+
- gemfiles/rails60.gemfile
|
188
|
+
- gemfiles/rails61.gemfile
|
230
189
|
- lib/rails_core_extensions.rb
|
231
190
|
- lib/rails_core_extensions/action_controller_sortable.rb
|
232
|
-
- lib/rails_core_extensions/action_view_currency_extensions.rb
|
233
191
|
- lib/rails_core_extensions/action_view_extensions.rb
|
234
192
|
- lib/rails_core_extensions/action_view_has_many_extensions.rb
|
235
193
|
- lib/rails_core_extensions/activatable.rb
|
236
194
|
- lib/rails_core_extensions/active_model_extensions.rb
|
237
|
-
- lib/rails_core_extensions/active_record_cache_all_attributes.rb
|
238
195
|
- lib/rails_core_extensions/active_record_cloning.rb
|
239
196
|
- lib/rails_core_extensions/active_record_extensions.rb
|
240
197
|
- lib/rails_core_extensions/active_record_liquid_extensions.rb
|
241
198
|
- lib/rails_core_extensions/active_support_concern.rb
|
242
|
-
- lib/rails_core_extensions/breadcrumb.rb
|
243
|
-
- lib/rails_core_extensions/caches_action_without_host.rb
|
244
199
|
- lib/rails_core_extensions/concurrency.rb
|
245
200
|
- lib/rails_core_extensions/position_initializer.rb
|
246
201
|
- lib/rails_core_extensions/railtie.rb
|
@@ -256,7 +211,6 @@ files:
|
|
256
211
|
- spec/active_model_extensions_spec.rb
|
257
212
|
- spec/active_record_cloning_spec.rb
|
258
213
|
- spec/active_record_extensions_spec.rb
|
259
|
-
- spec/breadcrumb_spec.rb
|
260
214
|
- spec/concurrency_spec.rb
|
261
215
|
- spec/en.yml
|
262
216
|
- spec/position_initializer_spec.rb
|
@@ -278,15 +232,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
278
232
|
requirements:
|
279
233
|
- - ">="
|
280
234
|
- !ruby/object:Gem::Version
|
281
|
-
version: '
|
235
|
+
version: '2.6'
|
282
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
237
|
requirements:
|
284
238
|
- - ">="
|
285
239
|
- !ruby/object:Gem::Version
|
286
240
|
version: '0'
|
287
241
|
requirements: []
|
288
|
-
|
289
|
-
rubygems_version: 2.7.6.2
|
242
|
+
rubygems_version: 3.2.3
|
290
243
|
signing_key:
|
291
244
|
specification_version: 4
|
292
245
|
summary: Set of extensions to core rails libraries.
|
@@ -296,7 +249,6 @@ test_files:
|
|
296
249
|
- spec/active_model_extensions_spec.rb
|
297
250
|
- spec/active_record_cloning_spec.rb
|
298
251
|
- spec/active_record_extensions_spec.rb
|
299
|
-
- spec/breadcrumb_spec.rb
|
300
252
|
- spec/concurrency_spec.rb
|
301
253
|
- spec/en.yml
|
302
254
|
- spec/position_initializer_spec.rb
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.4
|
4
|
-
- 2.5
|
5
|
-
matrix:
|
6
|
-
exclude:
|
7
|
-
- rvm: 2.4
|
8
|
-
gemfile: gemfiles/rails6.gemfile
|
9
|
-
|
10
|
-
script: "bundle exec rake spec"
|
11
|
-
gemfile:
|
12
|
-
- gemfiles/rails5.gemfile
|
13
|
-
- gemfiles/rails6.gemfile
|
14
|
-
sudo: false
|
15
|
-
cache: bundler
|
16
|
-
# Due to this issue, stil not resolved: travis-ci/travis-ci#8969
|
17
|
-
before_install:
|
18
|
-
- gem update --system
|
19
|
-
- gem install bundler
|
data/gemfiles/rails5.gemfile
DELETED
data/gemfiles/rails6.gemfile
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module ActionView
|
2
|
-
module Helpers
|
3
|
-
module FormTagHelper
|
4
|
-
# Create currency selector tag -- see select_tag for options
|
5
|
-
def currency_select_tag(name, current_value, options={})
|
6
|
-
selectable_options = []
|
7
|
-
selectable_options << ["--", nil] if options[:include_blank]
|
8
|
-
selectable_options += EnabledCurrency.all.map(&:iso_code) unless EnabledCurrency.all.empty?
|
9
|
-
select_tag(name, options_for_select(selectable_options, current_value), options)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module DateHelper
|
14
|
-
def currency_select(object_name, method, options = {})
|
15
|
-
value = options[:object] || EnabledCurrency.base_currency
|
16
|
-
currency_select_tag("#{object_name}[#{method}]", value, options.merge(:id => "#{object_name}_#{method}"))
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class FormBuilder
|
21
|
-
def currency_select(method, options = {})
|
22
|
-
@template.currency_select(@object_name, method, options.merge(:object => @object.send(method)))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module ActiveRecordCacheAllAttributes
|
2
|
-
def self.included(base)
|
3
|
-
base.extend ClassMethods
|
4
|
-
end
|
5
|
-
|
6
|
-
module InstanceMethods
|
7
|
-
def clear_attribute_cache
|
8
|
-
self.class.cache.delete("#{self.class.name}.attribute_cache")
|
9
|
-
self.class.clear_request_cache
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
def cache
|
15
|
-
Rails.cache
|
16
|
-
end
|
17
|
-
|
18
|
-
def clear_request_cache
|
19
|
-
@request_cache = nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def attribute_cache
|
23
|
-
cache_key = "#{name}.attribute_cache"
|
24
|
-
@request_cache ||= cache.read(cache_key) || generate_cache(cache_key)
|
25
|
-
end
|
26
|
-
|
27
|
-
def generate_attributes_hash
|
28
|
-
scope = self
|
29
|
-
scope = scope.ordered if respond_to?(:ordered)
|
30
|
-
Hash[scope.all.map { |o| [o.send(cache_attributes_by), o.attributes] }]
|
31
|
-
end
|
32
|
-
|
33
|
-
def generate_cache(cache_key)
|
34
|
-
cache_value = generate_attributes_hash
|
35
|
-
cache.write(cache_key, cache_value)
|
36
|
-
cache_value
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,170 +0,0 @@
|
|
1
|
-
module RailsCoreExtensions
|
2
|
-
|
3
|
-
module Breadcrumb
|
4
|
-
|
5
|
-
def breadcrumbs(object_or_nested_array = nil)
|
6
|
-
breadcrumbs_builder_for(object_or_nested_array).breadcrumbs
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def breadcrumbs_builder_for(object_or_nested_array)
|
13
|
-
BreadcrumbsBuilder.new(self, object_or_nested_array)
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
class BreadcrumbsBuilder
|
18
|
-
|
19
|
-
attr_reader :view, :object_or_nested_array, :path
|
20
|
-
|
21
|
-
def initialize(view, object_or_nested_array = nil)
|
22
|
-
@view = view
|
23
|
-
@object_or_nested_array = object_or_nested_array || path_builder.nested_array
|
24
|
-
@path = path_builder.collection_url
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
def breadcrumbs
|
29
|
-
view.content_tag :ul, :class =>'breadcrumb' do
|
30
|
-
(breadcrumb_for_parent + breadcrumb_for_collection + breadcrumb_for_action).html_safe
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def breadcrumb_for_object_link
|
36
|
-
breadcrumb_for link_to_object
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def breadcrumb_for_parent
|
43
|
-
parent = path_builder.parent
|
44
|
-
return ''.html_safe unless parent
|
45
|
-
BreadcrumbsBuilder.new(view, parent).breadcrumb_for_object_link
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
def breadcrumb_for_collection
|
50
|
-
breadcrumb_for view.link_to(object.class.table_name.titleize, path)
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
def breadcrumb_for_action
|
55
|
-
case action
|
56
|
-
when 'new' then breadcrumb_for('New', :class => 'active')
|
57
|
-
when 'edit' then breadcrumb_for_object + breadcrumb_for('Edit', :class => 'active')
|
58
|
-
else breadcrumb_for_object_name
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
def breadcrumb_for_object
|
64
|
-
if can_show?
|
65
|
-
breadcrumb_for_object_link
|
66
|
-
else
|
67
|
-
breadcrumb_for_object_name
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def breadcrumb_for(content, options = {})
|
73
|
-
view.content_tag :li, content, options
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
def breadcrumb_for_object_name
|
78
|
-
breadcrumb_for object_name.html_safe
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
def link_to_object
|
83
|
-
view.link_to object_name.html_safe, object_or_nested_array
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
def can_show?
|
88
|
-
view.controller.respond_to?(:show)
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
def action
|
93
|
-
return 'new' if object.new_record?
|
94
|
-
view.params[:action]
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
def object_name
|
99
|
-
if object.respond_to?(:name) && object.name.present?
|
100
|
-
object.name
|
101
|
-
else
|
102
|
-
object.to_s
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
def object
|
108
|
-
@object ||= Array(object_or_nested_array).last
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
def path_builder
|
113
|
-
@path_builder ||= if inherited_resources?
|
114
|
-
InheritedResourcesPathBuilder.new(view)
|
115
|
-
else
|
116
|
-
PathBuilder.new(view)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
def inherited_resources?
|
122
|
-
defined?(InheritedResources) && view.controller.responder == InheritedResources::Responder
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
PathBuilder = Struct.new(:view) do
|
129
|
-
def nested_array
|
130
|
-
(namespaces + [parent] + [view.current_object]).compact
|
131
|
-
end
|
132
|
-
|
133
|
-
def collection_url
|
134
|
-
view.objects_path
|
135
|
-
end
|
136
|
-
|
137
|
-
def parent
|
138
|
-
view.parent_object
|
139
|
-
end
|
140
|
-
|
141
|
-
def namespaces
|
142
|
-
return [] unless view.respond_to?(:namespaces)
|
143
|
-
Array(view.namespaces)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
|
148
|
-
InheritedResourcesPathBuilder = Struct.new(:view) do
|
149
|
-
def nested_array
|
150
|
-
if view.respond_to? :calculate_nested_array
|
151
|
-
view.calculate_nested_array
|
152
|
-
else
|
153
|
-
[parent, view.resource].compact
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def collection_url
|
158
|
-
view.collection_url
|
159
|
-
end
|
160
|
-
|
161
|
-
def parent
|
162
|
-
return view.parent.becomes(view.parent.class.base_class) if view.respond_to?(:parent)
|
163
|
-
view.parent_object
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
ActionView::Base.send(:include, RailsCoreExtensions::Breadcrumb) if defined?(ActionView::Base)
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module CachesActionWithoutHost
|
2
|
-
|
3
|
-
def self.included(controller)
|
4
|
-
controller.extend(ClassMethods)
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def caches_action_without_host(*args)
|
9
|
-
options = args.extract_options!
|
10
|
-
options ||= {}
|
11
|
-
options[:cache_path] ||= proc{|c| c.url_for(c.params).split(/\//, 4).last}
|
12
|
-
args << options
|
13
|
-
caches_action(*args)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
data/spec/breadcrumb_spec.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'rails_core_extensions/breadcrumb'
|
2
|
-
|
3
|
-
require 'action_view'
|
4
|
-
require 'action_view/helpers'
|
5
|
-
|
6
|
-
describe RailsCoreExtensions::Breadcrumb do
|
7
|
-
before do
|
8
|
-
class MockView
|
9
|
-
include ActionView::Helpers::TagHelper
|
10
|
-
include ActionView::Helpers::UrlHelper
|
11
|
-
include ActionView::Helpers::CaptureHelper
|
12
|
-
attr_accessor :output_buffer
|
13
|
-
include RailsCoreExtensions::Breadcrumb
|
14
|
-
|
15
|
-
attr_reader :params
|
16
|
-
|
17
|
-
def initialize(params)
|
18
|
-
@params = params
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
after { Object.send(:remove_const, 'MockView') }
|
24
|
-
|
25
|
-
subject { MockView.new(:action => action) }
|
26
|
-
|
27
|
-
let(:objects_path) { '/users' }
|
28
|
-
let(:parent) { nil }
|
29
|
-
|
30
|
-
before do
|
31
|
-
allow(subject).to receive(:objects_path) { objects_path }
|
32
|
-
allow(subject).to receive(:collection_url) { objects_path }
|
33
|
-
|
34
|
-
allow(subject).to receive(:parent) { parent }
|
35
|
-
allow(subject).to receive(:parent_object) { parent }
|
36
|
-
|
37
|
-
allow(subject).to receive(:controller) { double(:controller, :show => nil) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context '#breadcrumbs (* = link)' do
|
41
|
-
let(:user_class) { double(:table_name => 'users', :model_name => double(:singular_route_key => 'user')) }
|
42
|
-
let(:user) { double(:to_s => 'Alice', :new_record? => new_record, :class => user_class) }
|
43
|
-
context 'for a new record' do
|
44
|
-
let(:action) { 'new' }
|
45
|
-
let(:new_record) { true }
|
46
|
-
|
47
|
-
it 'should breadcrumb: *Users / New' do
|
48
|
-
result = subject.breadcrumbs(user)
|
49
|
-
expect(result).to be_html_safe
|
50
|
-
expect(result).to eq(
|
51
|
-
%q(<ul class="breadcrumb"><li><a href="/users">Users</a></li><li class="active">New</li></ul>)
|
52
|
-
)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'for a existing record' do
|
57
|
-
let(:new_record) { false }
|
58
|
-
|
59
|
-
context 'when editing' do
|
60
|
-
let(:action) { 'edit' }
|
61
|
-
it 'should breadcrumb: *Users / *Alice / Edit' do
|
62
|
-
expect(subject).to receive(:link_to).with('Users', '/users') {
|
63
|
-
'<a href="/users">Users</a>'.html_safe }
|
64
|
-
expect(subject).to receive(:link_to).with('Alice', user) {
|
65
|
-
'<a href="/users/1">Alice</a>'.html_safe }
|
66
|
-
result = subject.breadcrumbs(user)
|
67
|
-
expect(result).to be_html_safe
|
68
|
-
expect(result).to eq(
|
69
|
-
%q(<ul class="breadcrumb"><li><a href="/users">Users</a></li><li><a href="/users/1">Alice</a></li><li class="active">Edit</li></ul>)
|
70
|
-
)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when showing' do
|
75
|
-
let(:action) { 'show' }
|
76
|
-
it 'should breadcrumb: *Users / Alice' do
|
77
|
-
result = subject.breadcrumbs(user)
|
78
|
-
expect(result).to be_html_safe
|
79
|
-
expect(result).to eq(
|
80
|
-
%q(<ul class="breadcrumb"><li><a href="/users">Users</a></li><li>Alice</li></ul>)
|
81
|
-
)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|