Skip to content

Conversation

@LukasMalyszko
Copy link
Collaborator

@LukasMalyszko LukasMalyszko commented Dec 5, 2025

Description

This pull request introduces support for editing and updating existing pushes, including the necessary backend logic, validations, UI updates, and audit logging. It ensures that users can only edit their own, non-expired pushes, and that all changes are tracked in the audit log. The forms and UI are updated to reflect the edit/update workflow, providing a seamless experience for users updating their pushes.

Related Issue

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

Checklist

  • I've written tests (if applicable) for all new methods and classes that I created. (rake test)
  • I've added documentation as necessary so users can easily use and understand this feature/fix.

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Hello @LukasMalyszko, thank you for submitting a PR! We will respond as soon as possible.

@LukasMalyszko
Copy link
Collaborator Author

it got pretty big

@LukasMalyszko
Copy link
Collaborator Author

@ozovalihasan, @pglombardo
tests failing at:

  1. Failure:
    FilePushCreationTest#test_file_push_creation_with_limits [test/integration/file_push/file_push_creation_test.rb:108]:
    Expected response to be a <422: unprocessable_content>, but was a <302: Found> redirect to http://www.example.com/p/thmf1kq9aqu/preview
    Response body: .
    Expected: 422
    Actual: 302

  2. Failure:
    UrlCreationTest#test_url_creation_with_error [test/integration/url/url_creation_test.rb:65]:
    Expected response to be a <422: unprocessable_content>, but was a <302: Found> redirect to http://www.example.com/p/fay5lymcjmfuxb1l/preview
    Response body: .
    Expected: 422
    Actual: 302

547 runs, 3599 assertions, 2 failures, 0 errors, 0 skips
Can you check that? It's looks like it not related to my changes, or am I wrong? - not sure.


class AuditLog < ApplicationRecord
enum :kind, [:creation, :view, :failed_view, :expire, :failed_passphrase, :admin_view, :owner_view], validate: true
enum :kind, [:creation, :view, :failed_view, :expire, :failed_passphrase, :admin_view, :owner_view, :update], suffix: true, validate: true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why suffix: true?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand, update! method is tried to be added by enum, but same method is already defined by ActiveRecord, so it is raising an error. Changing kind of audit logs like updation should be enough instead of using suffix.

@pglombardo
Copy link
Owner

Can you check that? It's looks like it not related to my changes, or am I wrong? - not sure.

The tests pass on master branch so it's definitely something in this branch. I'll add a few comments/questions.

self.expired = true
self.expired_on = Time.current.utc
save
save(validate: false)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? I would think validations should still pass.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, validations shouldn't be disabled. There may be some edge cases to disable them, but I think it is not necessary to disable them when editing pushes feature is implemented.

user: @luca
)

# Manually set expired without triggering validations
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - if skipping validations is needed, we should explain why.

@pglombardo
Copy link
Owner

Ok I think I found the cause of the test failures. It's because you are skipping validations with save(validations: false). Let's figure out why you needed that and then the tests should pass once restored.

The model validations enforce user preferences and app settings. Without those, we break a lot of functionality.

@LukasMalyszko
Copy link
Collaborator Author

Thanks for the feedback; it'll help me understand the issue. I definitely need to spend more time on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants