rails_core_extensions 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-style.yml +4 -30
- data/.travis.yml +10 -7
- data/CHANGELOG.md +9 -0
- data/gemfiles/{rails4.gemfile → rails6.gemfile} +1 -1
- data/lib/rails_core_extensions/action_view_extensions.rb +3 -3
- data/lib/rails_core_extensions/sortable.rb +7 -10
- data/lib/rails_core_extensions/version.rb +1 -1
- data/rails_core_extensions.gemspec +4 -3
- data/spec/action_controller_sortable_spec.rb +11 -2
- data/spec/action_view_extensions_spec.rb +24 -9
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7a7bd9b6bb639dc50a122b94ee7b46128875ab70b493d2c0846f795308ae5ef
|
4
|
+
data.tar.gz: b5ed7c23cb5b1102a7332c31c7df5291a8b6f19fd3417283af991e122ce8cbd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f9327c73a62ed82c97dac61fa7eed4bb56ab1c54a1993e7299abdddb6c3c3d316889e422f7c6eaf889a7819628f84599b86c565740034053fd4e9674dbc06d5
|
7
|
+
data.tar.gz: 3afa1de1ffe2875da34aa4cacff8081101f979c9c92d5528956394ea32c35176904368c888cfb4c58c82d9cd169a5d33064ac9ce6e883020b9b90a19d1736ad3
|
data/.ruby-style.yml
CHANGED
@@ -35,7 +35,6 @@ Style/IfUnlessModifier:
|
|
35
35
|
Description: Favor modifier if/unless usage when you have a single-line body.
|
36
36
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
37
37
|
Enabled: false
|
38
|
-
MaxLineLength: 100
|
39
38
|
Style/OptionHash:
|
40
39
|
Description: Don't use option hashes when you can use keyword arguments.
|
41
40
|
Enabled: false
|
@@ -98,40 +97,16 @@ Style/SingleLineMethods:
|
|
98
97
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
99
98
|
Enabled: false
|
100
99
|
AllowIfMethodIsEmpty: true
|
101
|
-
Style/StringLiterals:
|
102
|
-
Description: Checks if uses of quotes match the configured preference.
|
103
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
104
|
-
Enabled: true
|
105
|
-
EnforcedStyle: single_quotes
|
106
|
-
SupportedStyles:
|
107
|
-
- single_quotes
|
108
|
-
- double_quotes
|
109
|
-
Style/StringLiteralsInInterpolation:
|
110
|
-
Description: Checks if uses of quotes inside expressions in interpolated strings
|
111
|
-
match the configured preference.
|
112
|
-
Enabled: true
|
113
|
-
EnforcedStyle: single_quotes
|
114
|
-
SupportedStyles:
|
115
|
-
- single_quotes
|
116
|
-
- double_quotes
|
117
100
|
Style/TrailingCommaInArguments:
|
118
101
|
Description: Checks for trailing comma in argument lists.
|
119
102
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
|
120
103
|
EnforcedStyleForMultiline: comma
|
121
|
-
SupportedStyles:
|
122
|
-
- comma
|
123
|
-
- consistent_comma
|
124
|
-
- no_comma
|
125
104
|
Enabled: true
|
126
|
-
Style/
|
105
|
+
Style/TrailingCommaInArrayLiteral:
|
127
106
|
Description: Checks for trailing comma in array and hash literals.
|
128
107
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
|
129
108
|
EnforcedStyleForMultiline: comma
|
130
|
-
|
131
|
-
- comma
|
132
|
-
- consistent_comma
|
133
|
-
- no_comma
|
134
|
-
Enabled: true
|
109
|
+
Enabled: true
|
135
110
|
Metrics/AbcSize:
|
136
111
|
Description: A calculated magnitude based on number of assignments, branches, and
|
137
112
|
conditions.
|
@@ -235,9 +210,8 @@ Lint/HandleExceptions:
|
|
235
210
|
Description: Don't suppress exception.
|
236
211
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
237
212
|
Enabled: false
|
238
|
-
Lint/LiteralInCondition:
|
239
|
-
Description: Checks of literals used in conditions.
|
240
|
-
Enabled: false
|
241
213
|
Lint/LiteralInInterpolation:
|
242
214
|
Description: Checks for literals used in interpolation.
|
243
215
|
Enabled: false
|
216
|
+
Style/FrozenStringLiteralComment:
|
217
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.3
|
4
3
|
- 2.4
|
5
4
|
- 2.5
|
5
|
+
matrix:
|
6
|
+
exclude:
|
7
|
+
- rvm: 2.4
|
8
|
+
gemfile: gemfiles/rails6.gemfile
|
9
|
+
|
6
10
|
script: "bundle exec rake spec"
|
7
11
|
gemfile:
|
8
|
-
- gemfiles/rails4.gemfile
|
9
12
|
- gemfiles/rails5.gemfile
|
10
|
-
|
11
|
-
email:
|
12
|
-
- support@travellink.com.au
|
13
|
-
flowdock:
|
14
|
-
secure: A0XTB5fVkDI9PSeyA4kMIckB4EPdoBlCIae+zatkcqlUJcqTc9wMFSrlnjzA4x+ramqGlwprPXUtEGVVEJwBcoaUjSOnNqZjeRAE1HuZ3D91/UaXZArp+skTGkO/qqek6pSYsAwODN5Q/Fr0qpV6cRzUuQ9nvGA/8sg/Ano2Cno=
|
13
|
+
- gemfiles/rails6.gemfile
|
15
14
|
sudo: false
|
16
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/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.6.0
|
4
|
+
|
5
|
+
* [TT-5542] Remove Rails 4 support
|
6
|
+
* [TT-5642] Fixed sortable so it can sort on empty scopes
|
7
|
+
|
8
|
+
## 0.5.0
|
9
|
+
|
10
|
+
* Support include_blank properly (was broken)
|
11
|
+
|
3
12
|
## 0.4.0 (Removes Rails3 Support)
|
4
13
|
|
5
14
|
* [TT-3778] Store the cacheable attributes in memory for the duration of the request
|
@@ -52,9 +52,9 @@ module RailsCoreExtensions
|
|
52
52
|
def boolean_select_tag(name, *args)
|
53
53
|
options = args.extract_options!
|
54
54
|
options ||= {}
|
55
|
-
|
56
|
-
|
57
|
-
select_tag name,
|
55
|
+
yes_no_opts = [%w[Yes 1], %w[No 0]]
|
56
|
+
option_tags = options_for_select(yes_no_opts, options[:selected])
|
57
|
+
select_tag name, option_tags, options.except(:selected)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -15,21 +15,18 @@ module RailsCoreExtensions
|
|
15
15
|
|
16
16
|
def sort
|
17
17
|
scope = @params[:scope].try(:to_sym)
|
18
|
+
@params[scope] = nil if @params[scope].blank?
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
if params_collection.blank?
|
25
|
-
name = "#{scope.to_s.gsub('_id', '')}_#{@params[scope]}_body".to_sym
|
26
|
-
params_collection = @params[name]
|
20
|
+
body_key = @controller_name.singularize + (@params[scope] ? "_#{@params[scope]}" : '')
|
21
|
+
sorted_id_list = @params["#{body_key}_body".to_sym]
|
22
|
+
if sorted_id_list.blank?
|
23
|
+
sorted_id_list = @params["#{scope.to_s.gsub('_id', '')}_#{@params[scope]}_body".to_sym]
|
27
24
|
end
|
28
25
|
|
29
26
|
collection = @klass.reorder(:position)
|
30
|
-
collection = collection.where(@params.slice(scope
|
27
|
+
collection = collection.where(@params.slice(scope)) unless scope.blank?
|
31
28
|
|
32
|
-
sort_collection(collection,
|
29
|
+
sort_collection(collection, sorted_id_list.map(&:to_i))
|
33
30
|
end
|
34
31
|
|
35
32
|
private
|
@@ -19,16 +19,17 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_dependency 'activerecord', ['>=
|
23
|
-
spec.add_dependency 'actionpack', ['>=
|
22
|
+
spec.add_dependency 'activerecord', ['>= 5.0.0']
|
23
|
+
spec.add_dependency 'actionpack', ['>= 5.0.0']
|
24
24
|
|
25
|
-
spec.add_development_dependency 'bundler', '~>
|
25
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
26
|
spec.add_development_dependency 'rake'
|
27
27
|
spec.add_development_dependency 'rspec'
|
28
28
|
spec.add_development_dependency 'activerecord-nulldb-adapter'
|
29
29
|
spec.add_development_dependency 'coverage-kit'
|
30
30
|
spec.add_development_dependency 'simplecov-rcov'
|
31
31
|
spec.add_development_dependency 'coveralls'
|
32
|
+
spec.add_development_dependency 'rubocop'
|
32
33
|
spec.add_development_dependency 'sqlite3'
|
33
34
|
spec.add_development_dependency 'travis'
|
34
35
|
|
@@ -26,10 +26,9 @@ describe RailsCoreExtensions::Sortable do
|
|
26
26
|
models.each(&:destroy)
|
27
27
|
end
|
28
28
|
|
29
|
-
let(:params) { { model_body: [one.id, thr.id, two.id] } }
|
30
29
|
subject { RailsCoreExtensions::Sortable.new(params, 'models') }
|
31
30
|
|
32
|
-
|
31
|
+
RSpec.shared_examples 'unscoped' do
|
33
32
|
let(:scope) { Model.reorder(:position) }
|
34
33
|
specify { expect(scope.pluck(:name)).to eq %w(One Two Thr) }
|
35
34
|
it 'should correctly sort' do
|
@@ -38,6 +37,16 @@ describe RailsCoreExtensions::Sortable do
|
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
40
|
+
describe 'when unscoped due to blank scope' do
|
41
|
+
let(:params) { { model_body: [one.id, thr.id, two.id], scope: "" } }
|
42
|
+
it_behaves_like 'unscoped'
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'when unscoped due to lack of scope' do
|
46
|
+
let(:params) { { model_body: [one.id, thr.id, two.id] } }
|
47
|
+
it_behaves_like 'unscoped'
|
48
|
+
end
|
49
|
+
|
41
50
|
describe 'when scoped' do
|
42
51
|
let(:scope) { Model.where(category_id: 1).reorder(:position) }
|
43
52
|
specify { expect(scope.pluck(:name)).to eq %w(One Two) }
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "rails_core_extensions/action_view_extensions"
|
2
2
|
|
3
|
-
require
|
3
|
+
require "action_view"
|
4
4
|
|
5
5
|
describe RailsCoreExtensions::ActionViewExtensions do
|
6
6
|
before do
|
@@ -11,15 +11,30 @@ describe RailsCoreExtensions::ActionViewExtensions do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
after { Object.send(:remove_const,
|
14
|
+
after { Object.send(:remove_const, "TestModel1") }
|
15
15
|
|
16
|
-
|
16
|
+
let(:helper) { TestModel1.new }
|
17
17
|
|
18
|
-
context
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
context "#boolean_select_tag" do
|
19
|
+
let(:yes_no) { [%w[Yes 1], %w[No 0]] }
|
20
|
+
subject { helper.boolean_select_tag("name", args) }
|
21
|
+
|
22
|
+
context "when elements selected" do
|
23
|
+
let(:args) { { selected: 0 } }
|
24
|
+
let(:options) { helper.options_for_select(yes_no, selected: "0") }
|
25
|
+
|
26
|
+
it { is_expected.to eq helper.select_tag("name", options) }
|
27
|
+
|
28
|
+
context "and other options passed" do
|
29
|
+
let(:args) { { selected: "0", include_blank: "All" } }
|
30
|
+
it {
|
31
|
+
is_expected.to eq helper.select_tag(
|
32
|
+
"name",
|
33
|
+
options,
|
34
|
+
include_blank: "All",
|
35
|
+
)
|
36
|
+
}
|
37
|
+
end
|
23
38
|
end
|
24
39
|
end
|
25
40
|
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.6.0
|
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: 2019-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -17,42 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 5.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: 5.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: 5.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: 5.0.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '2.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '2.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,6 +137,20 @@ dependencies:
|
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
140
154
|
- !ruby/object:Gem::Dependency
|
141
155
|
name: sqlite3
|
142
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,8 +225,8 @@ files:
|
|
211
225
|
- LICENSE.txt
|
212
226
|
- README.md
|
213
227
|
- Rakefile
|
214
|
-
- gemfiles/rails4.gemfile
|
215
228
|
- gemfiles/rails5.gemfile
|
229
|
+
- gemfiles/rails6.gemfile
|
216
230
|
- lib/rails_core_extensions.rb
|
217
231
|
- lib/rails_core_extensions/action_controller_sortable.rb
|
218
232
|
- lib/rails_core_extensions/action_view_currency_extensions.rb
|