rails_core_extensions 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccc0583ffb6264c6f3a3c4ec35caf8028c263dc37403eae6417a2e2a398b01c9
4
- data.tar.gz: e332a69c6ed44ab4cec2f12608a0af873ab799d6f7274f818ab9c211eff05ee2
3
+ metadata.gz: abf2a60c82dfb1b0eab8b44ce552adc6541a2cde2b02749e6e3fabcf1781ac71
4
+ data.tar.gz: 1b453d160782af795a187f15004c874b7794092396daec131e9e3f1c06f98ebf
5
5
  SHA512:
6
- metadata.gz: c73627135e3553892c98facf3071f2599db2f222d0c35e9b8fa9a0f372fa3f40dbdf10f42ccfc2d5df20fa37ae6136aba5199c98e8ef093f406989d16dd23443
7
- data.tar.gz: 634791e2c66ab5972318a1a8f44c15ba00dd6257ae7110487c56ca2f9c8406dcf779c94558606242923ec626541486aa0bfe53913fb2cdc28cf3a9ba8422bdcd
6
+ metadata.gz: 965728be60a5bd63fe324c32a2e72c487c9871a0d71778dca58bae6588dc1bbf33ff9beb1c9de6899fde75b3ec1d6bad1a0a9c61de384f25bb8c55cda7ca0224
7
+ data.tar.gz: 6dca302b72068a256a70c4b61bc0498b532c67348af7df9585aaa7781ff0809fea5b76a0224d2042916422df042c60136b10699f6a583ccfdcaf9500b6ec0635
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.14.0
4
+
5
+ - [PLAT-1135] Remove `enum_int` as we have now fully migrated to rails native `enum`
6
+
7
+ ## 0.13.2
8
+
9
+ - [PLAT-390] Fix broken `action_view` extensions
10
+
3
11
  ## 0.13.1
4
12
 
5
13
  - [PLAT-384] Fix the liquid extension
@@ -9,28 +9,6 @@ module ActiveRecordExtensions
9
9
  establish_connection("#{key}_#{Rails.env}")
10
10
  end
11
11
 
12
- def enum_int(field, values, options = {})
13
- const_set("#{field.to_s.upcase}_OPTIONS", values)
14
-
15
- select_options = values.map.with_index{|v, i| [v.to_s.humanize, i]}
16
- const_set("#{field.to_s.upcase}_SELECT_OPTIONS", select_options)
17
-
18
- values.each.with_index do |value, i|
19
- const_set("#{field.to_s.upcase}_#{value.to_s.upcase}", i)
20
- method_name = options[:short_name] ? "#{value}?" : "#{field}_#{value}?"
21
- class_eval <<-ENUM
22
- def #{method_name}
23
- #{field} == #{i}
24
- end
25
- ENUM
26
- end
27
- class_eval <<-ENUM
28
- def #{field}_name
29
- #{field.to_s.upcase}_OPTIONS[#{field}]
30
- end
31
- ENUM
32
- end
33
-
34
12
  def optional_fields(*possible_fields)
35
13
  @optional_fields_loader = possible_fields.pop if possible_fields.last.is_a?(Proc)
36
14
 
@@ -1,3 +1,3 @@
1
1
  module RailsCoreExtensions
2
- VERSION = '0.13.1'
2
+ VERSION = '0.14.0'
3
3
  end
@@ -20,7 +20,7 @@ module RailsCoreExtensions
20
20
  require 'rails_core_extensions/action_view_extensions'
21
21
  require 'rails_core_extensions/action_view_has_many_extensions'
22
22
 
23
- ActiveSupport.on_load(:active_view) do
23
+ ActiveSupport.on_load(:action_view) do
24
24
  ActionView::Base.send(:include, RailsCoreExtensions::ActionViewExtensions)
25
25
  end
26
26
  end
@@ -22,52 +22,6 @@ describe "optional_fields" do
22
22
  end
23
23
  end
24
24
 
25
- describe 'enum_int' do
26
- let(:model_class) {
27
- Class.new(ActiveRecord::Base) do
28
- enum_int :category_id, %w(one two thr)
29
- end
30
- }
31
- before do
32
- connect_to_sqlite
33
- stub_const 'Model', model_class
34
- end
35
- let(:one) { Model.new(category_id: 'one') }
36
-
37
- it 'should define constants' do
38
- expect(Model::CATEGORY_ID_OPTIONS).to eq %w(one two thr)
39
- expect(Model::CATEGORY_ID_ONE).to eq 0
40
- expect(Model::CATEGORY_ID_TWO).to eq 1
41
- expect(Model::CATEGORY_ID_THR).to eq 2
42
- end
43
-
44
- it 'should define methods' do
45
- expect(one.category_id_one?).to be true
46
- expect(one.category_id_two?).to be false
47
- expect(one.category_id_thr?).to be false
48
- end
49
-
50
- it 'should define select options' do
51
- expect(Model::CATEGORY_ID_SELECT_OPTIONS).to eq([
52
- ['One', 0], ['Two', 1], ['Thr', 2]
53
- ])
54
- end
55
-
56
- context 'when short name' do
57
- let(:model_class) {
58
- Class.new(ActiveRecord::Base) do
59
- enum_int :category_id, %w(one two thr), short_name: true
60
- end
61
- }
62
-
63
- it 'should define methods' do
64
- expect(one.one?).to be true
65
- expect(one.two?).to be false
66
- expect(one.thr?).to be false
67
- end
68
- end
69
- end
70
-
71
25
  describe RailsCoreExtensions::ActionControllerSortable do
72
26
  class NormalController < ActionController::Base
73
27
  end
@@ -1,3 +1,3 @@
1
1
  require 'coverage/kit'
2
2
 
3
- Coverage::Kit.setup(minimum_coverage: 84.1)
3
+ Coverage::Kit.setup(minimum_coverage: 83.5)
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.13.1
4
+ version: 0.14.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: 2022-07-04 00:00:00.000000000 Z
12
+ date: 2022-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord