-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move store_credits actions to their own controller
The admin store credit flow is complicated enough and has enough of its own actions that it should really be in its own controller rather than squished into the users controller.
- Loading branch information
1 parent
81c605c
commit 07a2d3a
Showing
5 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
admin/app/controllers/solidus_admin/store_credits_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidusAdmin | ||
class StoreCreditsController < SolidusAdmin::BaseController | ||
before_action :set_user | ||
|
||
def index | ||
@store_credits = Spree::StoreCredit.where(user_id: @user.id).order(id: :desc) | ||
|
||
respond_to do |format| | ||
format.html { render component("users/store_credits/index").new(user: @user, store_credits: @store_credits) } | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_user | ||
@user = Spree.user_class.find(params[:id]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe SolidusAdmin::StoreCreditsController, type: :request do | ||
let(:admin_user) { create(:admin_user) } | ||
let(:user) { create(:user) } | ||
let!(:store_credit) { create(:store_credit, user: user) } | ||
|
||
before do | ||
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(admin_user) | ||
end | ||
|
||
describe "GET /store_credits" do | ||
it "renders the store credits template with a 200 OK status" do | ||
get solidus_admin.store_credits_user_path(user) | ||
expect(response).to have_http_status(:ok) | ||
expect(response.body).to include(store_credit.amount.to_s) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters