protected_attributes_continued 1.8.1 → 1.9.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: 5e881236bacf8378d98f06eb98269417a5082383de65360f522e524062fbcdfb
4
- data.tar.gz: 45f598ce1954ed9542934e676af3ac8f53e6b5c6dea2c35e87b3100721d2522a
3
+ metadata.gz: 188295cb5aeab9eb8b0f161215dffcb78adb55edd7b7672ae9fbaa69695b9864
4
+ data.tar.gz: bce171e972cfbf191ec7bd2f29aa9126f51b1b0daacfd15aadefcbf48356e8de
5
5
  SHA512:
6
- metadata.gz: 30fb108c2db47feeb17c7787dc1427a44e93b7ac47450d79f20d59a3bf814d3f8314eb42ee71a76bd3e1f54dbec508d56e917ab0f57d5a6c7c7e5a68a4ac2d8d
7
- data.tar.gz: '0486645654d15f177a2ba9abd27069c598b9d08884a7beb4db9d7813ce79604265d0eab9263f937aa0957c963cbd66dc435d4628993381793789068d04d0573b'
6
+ metadata.gz: a024699f714e830b23db791904529f23bcdbbea10d9c34dff637c9bd4f1c958ec3940dee8f3022cfc8ff0ba24dbe95f07b8e881dba96994846a5bd3d75c45468
7
+ data.tar.gz: 32c0066a02eef87f6bffa576a2815a10f2827b336fff020d9c96651f33903e8dd608082d94a970a139be105fc2f92d8a90343efba7228f93df18b96ddd5d07e1
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Protected Attributes Continued
2
2
  <a href="https://badge.fury.io/rb/protected_attributes_continued" target="_blank"><img height="21" style='border:0px;height:21px;' border='0' src="https://badge.fury.io/rb/protected_attributes_continued.svg" alt="Gem Version"></a>
3
3
  <a href='https://github.com/westonganger/protected_attributes_continued/actions' target='_blank'><img src="https://github.com/westonganger/protected_attributes_continued/workflows/Tests/badge.svg" style="max-width:100%;" height='21' style='border:0px;height:21px;' border='0' alt="CI Status"></a>
4
- <a href='https://rubygems.org/gems/protected_attributes_continued' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://ruby-gem-downloads-badge.herokuapp.com/protected_attributes_continued?label=rubygems&type=total&total_label=downloads&color=brightgreen' border='0' alt='RubyGems Downloads' /></a>
4
+ <a href='https://rubygems.org/gems/protected_attributes_continued' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://img.shields.io/gem/dt/protected_attributes_continued?color=brightgreen&label=Rubygems%20Downloads' border='0' alt='RubyGems Downloads' /></a>
5
5
 
6
6
  > This is the community continued version of [`protected_attributes`](https://github.com/rails/protected_attributes) for Rails 5+. The Rails team dropped this feature and switched to `strong_parameters`. However some applications simply cannot be upgraded or the reduced granularity in params management is a non-issue. To continue supporting this feature going forward we continue the work here.
7
7
 
@@ -126,13 +126,13 @@ class Post < ActiveRecord::Base
126
126
  params.permit(:post).permit(*PERMITTED_ATTRIBUTES)
127
127
  end
128
128
 
129
- PERMITTED_PARAMETERS = [
129
+ PERMITTED_ATTRIBUTES = [
130
130
  :id,
131
131
  :name,
132
132
  :content,
133
133
  :published_at,
134
134
  {
135
- comments_attributes: Comment::PERMITTED_PARAMETERS,
135
+ comments_attributes: Comment::PERMITTED_ATTRIBUTES,
136
136
  }
137
137
  ].freeze
138
138
 
@@ -55,6 +55,18 @@ module ActiveRecord
55
55
  end
56
56
  end
57
57
  private :create_record
58
+
59
+ if ActiveRecord.version >= Gem::Version.new("6.0.4") && ActiveRecord.version < Gem::Version.new("6.1")
60
+ undef :build_record
61
+
62
+ def build_record(attributes, options)
63
+ previous = klass.current_scope(true) if block_given?
64
+ super
65
+ ensure
66
+ klass.current_scope = previous if previous
67
+ end
68
+ private :build_record
69
+ end
58
70
  end
59
71
 
60
72
  class CollectionProxy
@@ -92,7 +104,23 @@ module ActiveRecord
92
104
  end
93
105
 
94
106
  class HasManyThroughAssociation
95
- if ActiveRecord.version >= Gem::Version.new('5.2.3')
107
+ if ActiveRecord.version >= Gem::Version.new('6.1')
108
+ undef :build_through_record
109
+ def build_through_record(record)
110
+ @through_records[record] ||= begin
111
+ ensure_mutable
112
+
113
+ attributes = through_scope_attributes
114
+ attributes[source_reflection.name] = record
115
+ attributes[source_reflection.foreign_type] = options[:source_type] if options[:source_type]
116
+
117
+ # Pass in `without_protection: true` here because `options_for_through_record`
118
+ # was removed in https://github.com/rails/rails/pull/35799
119
+ through_association.build(attributes, without_protection: true)
120
+ end
121
+ end
122
+ private :build_through_record
123
+ elsif ActiveRecord.version >= Gem::Version.new('5.2.3')
96
124
  undef :build_through_record
97
125
  def build_through_record(record)
98
126
  @through_records[record.object_id] ||= begin
@@ -21,6 +21,8 @@ class ActiveRecord::Base
21
21
  include ActiveRecord::MassAssignmentSecurity::Inheritance
22
22
  end
23
23
 
24
- class ActiveRecord::SchemaMigration < ActiveRecord::Base
25
- attr_accessible :version
24
+ if ActiveRecord.version <= Gem::Version.new("7.0")
25
+ class ActiveRecord::SchemaMigration < ActiveRecord::Base
26
+ attr_accessible :version
27
+ end
26
28
  end
@@ -1,3 +1,3 @@
1
1
  module ProtectedAttributes
2
- VERSION = "1.8.1".freeze
2
+ VERSION = "1.9.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protected_attributes_continued
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-24 00:00:00.000000000 Z
11
+ date: 2023-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.4.0
83
- - !ruby/object:Gem::Dependency
84
- name: appraisal
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  description: Protect attributes from mass assignment
98
84
  email:
99
85
  - weston@westonganger.com
@@ -126,7 +112,7 @@ homepage: https://github.com/westonganger/protected_attributes_continued
126
112
  licenses:
127
113
  - MIT
128
114
  metadata: {}
129
- post_install_message:
115
+ post_install_message:
130
116
  rdoc_options: []
131
117
  require_paths:
132
118
  - lib
@@ -141,8 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
127
  - !ruby/object:Gem::Version
142
128
  version: '0'
143
129
  requirements: []
144
- rubygems_version: 3.1.2
145
- signing_key:
130
+ rubygems_version: 3.4.6
131
+ signing_key:
146
132
  specification_version: 4
147
133
  summary: Protect attributes from mass assignment in Active Record models
148
134
  test_files: []