Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore status changing permission check if previous value is not a string #1661

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def can_set_workflow_status
if ::Workflow::Workflow.is_field_name_a_workflow?(self.field_name)
options = self.workflow_options_and_roles
value = self.value&.to_sym
old_value = self.previous_value&.to_sym
old_value = self.previous_value
return true unless old_value.is_a?(String)
old_value = old_value.to_sym
self.previous_status = old_value
user = User.current

Expand Down
15 changes: 15 additions & 0 deletions test/models/dynamic_annotation/field_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@ def field_formatter_name_response
assert_equal 'https://archive.org/web/', f.reload.value[0]['url']
end

test "should ignore permission check for changing status if previous value is empty" do
create_verification_status_stuff
pm = create_project_media
a = create_dynamic_annotation annotation_type: 'verification_status', annotated: pm, set_fields: { verification_status_status: 'undetermined' }.to_json
assert_equal 'undetermined', pm.reload.last_status
f = a.get_field('verification_status_status')
f.update_column(:value, [])
f = DynamicAnnotation::Field.find(f.id)
assert_nothing_raised do
f.value = 'false'
f.save!
end
assert_equal 'false', pm.reload.last_status
end

protected

def create_geojson_field
Expand Down
Loading