rails_core_extensions 0.13.2 → 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: b9a3bc99415c6959119365c5b542dc8ae3c912d004d7a4ae809755c7eeaccc44
4
- data.tar.gz: 3a3db36a2823a7116674253ede3efe09222829285e038561de663b33bf8b9671
3
+ metadata.gz: abf2a60c82dfb1b0eab8b44ce552adc6541a2cde2b02749e6e3fabcf1781ac71
4
+ data.tar.gz: 1b453d160782af795a187f15004c874b7794092396daec131e9e3f1c06f98ebf
5
5
  SHA512:
6
- metadata.gz: 2b02c74b69ba727097ecea9edbba9db615c517ac15f9573c12770f0ce9893bb31d5beaa8701e259854db15fe41f7f3b49fc269784fabdcf3d51a7c6d0243aec2
7
- data.tar.gz: deeab7f200cd2439ea720c4c2338dd82d9feb370be4d650bd25675d6cab826c6701e95bdc716f133740a95a083e06d07d977d5c7a7510049a6184ff4a2a10f63
6
+ metadata.gz: 965728be60a5bd63fe324c32a2e72c487c9871a0d71778dca58bae6588dc1bbf33ff9beb1c9de6899fde75b3ec1d6bad1a0a9c61de384f25bb8c55cda7ca0224
7
+ data.tar.gz: 6dca302b72068a256a70c4b61bc0498b532c67348af7df9585aaa7781ff0809fea5b76a0224d2042916422df042c60136b10699f6a583ccfdcaf9500b6ec0635
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  ## 0.13.2
4
8
 
5
9
  - [PLAT-390] Fix broken `action_view` extensions
@@ -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.2'
2
+ VERSION = '0.14.0'
3
3
  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.2
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