Skip to content

Commit

Permalink
Ignore status changing permission check if previous value is not a st…
Browse files Browse the repository at this point in the history
…ring.

Fixes CV2-3764.
  • Loading branch information
caiosba committed Sep 21, 2023
1 parent 7039a67 commit 6fb9b49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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

0 comments on commit 6fb9b49

Please sign in to comment.