Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OHR Support
Manage
Activity
Members
Labels
Plan
Issues
97
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
OHR Support
Commits
0320517d
Commit
0320517d
authored
14 years ago
by
Gregor Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
[
#282
] Make safe_attributes work with symbol keys
parent
b5b36844
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/redmine/safe_attributes.rb
+1
-1
1 addition, 1 deletion
lib/redmine/safe_attributes.rb
test/unit/lib/redmine/safe_attributes_test.rb
+7
-0
7 additions, 0 deletions
test/unit/lib/redmine/safe_attributes_test.rb
with
8 additions
and
1 deletion
lib/redmine/safe_attributes.rb
+
1
−
1
View file @
0320517d
...
...
@@ -67,7 +67,7 @@ module Redmine
# # => {'title' => 'My book'}
def
delete_unsafe_attributes
(
attrs
,
user
=
User
.
current
)
safe
=
safe_attribute_names
(
user
)
attrs
.
dup
.
delete_if
{
|
k
,
v
|
!
safe
.
include?
(
k
)}
attrs
.
dup
.
delete_if
{
|
k
,
v
|
!
safe
.
include?
(
k
.
to_s
)}
end
# Sets attributes from attrs that are safe
...
...
This diff is collapsed.
Click to expand it.
test/unit/lib/redmine/safe_attributes_test.rb
+
7
−
0
View file @
0320517d
...
...
@@ -90,6 +90,13 @@ class Redmine::SafeAttributesTest < ActiveSupport::TestCase
assert_equal
'jsmith'
,
p
.
login
end
def
test_with_indifferent_access
p
=
Person
.
new
p
.
safe_attributes
=
{
'firstname'
=>
'Jack'
,
:lastname
=>
'Miller'
}
assert_equal
'Jack'
,
p
.
firstname
assert_equal
'Miller'
,
p
.
lastname
end
def
test_use_safe_attributes_in_subclasses
b
=
Book
.
new
p
=
PublishedBook
.
new
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment