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

[Admin] Store Credit Reasons edit/update & New request specs to appease Codecov #5821

Conversation

MadelineCollier
Copy link
Contributor

@MadelineCollier MadelineCollier commented Aug 13, 2024

This PR finishes off this issue but it doesn't have an issue ID yet as the issue is still in draft and there is (still) a GitHub bug preventing opening the issue.

This PR migrates the editing/updating of existing store credit reasons to the new admin interface, following the existing pattern used for tax categories.

The form is rendered via a modal dialog on the store credit reasons list by leveraging Turbo frames. Successful updating leads to a turbo stream page refresh, which updates the existing list preserving the query params and the scroll position, for a consistent UX.

The second part of this PR is adding new request specs to appease codecov, which was not happy with the coverage provided solely by our feature specs. I will add similar request specs for all the past PRs I have put up if/when this change has proven to increase the coverage percentage.

The attached video shows the functionality visually:

Screen.Recording.2024-08-13.at.4.20.47.PM.mov

Summary

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@MadelineCollier MadelineCollier force-pushed the admin-update-store-credit-reason branch 2 times, most recently from 32f76f8 to 2ea57ef Compare August 13, 2024 13:07
Our coverage percentage has been dropping by a few percentage points on
the last couple PRs due to our feature tests only really testing the
happy paths of the admin and not really covering every possible
controller redirect and format-specific response. Adidng these specs
should win us back those coverage points.
@MadelineCollier MadelineCollier changed the title Appease codecov with new admin request specs [Admin] Store Credit Reasons edit/update & New request specs to appease Codecov Aug 13, 2024
Copy link

codecov bot commented Aug 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.79%. Comparing base (d99aaf2) to head (24a9259).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5821      +/-   ##
==========================================
+ Coverage   88.76%   88.79%   +0.02%     
==========================================
  Files         736      737       +1     
  Lines       17201    17227      +26     
==========================================
+ Hits        15269    15296      +27     
+ Misses       1932     1931       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MadelineCollier MadelineCollier marked this pull request as ready for review August 13, 2024 14:23
@MadelineCollier MadelineCollier requested a review from a team as a code owner August 13, 2024 14:23
@MadelineCollier
Copy link
Contributor Author

Screenshot 2024-08-13 at 4 26 46 PM

Nice, it looks like codecov is happy at last.

It seems like the only thing not covered by these new specs is this one private method:

 # admin/app/controllers/solidus_admin/store_credit_reasons_controller.rb

    private
    def load_store_credit_reason
      @store_credit_reason = Spree::StoreCreditReason.find_by!(id: params[:id])
      authorize! action_name, @store_credit_reason
    end

I actually don't see being called anywhere. @rainerdema @elia This looks like it's a common pattern in the new admin controllers, do you know what these load methods are (/were?) being used for?

@elia
Copy link
Member

elia commented Aug 13, 2024

I actually don't see being called anywhere. @rainerdema @elia This looks like it's a common pattern in the new admin controllers, do you know what these load methods are (/were?) being used for?

@MadelineCollier I think you can remove it, must be a leftover from a copy/paste.

@MadelineCollier MadelineCollier merged commit 7d2d97a into solidusio:main Aug 13, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants