-
-
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.
Merge pull request #5294 from solidusio/elia/admin/account-path-redirect
[Admin] Use the current admin user page as the account path
- Loading branch information
Showing
6 changed files
with
32 additions
and
24 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -3,20 +3,14 @@ | |
require 'spec_helper' | ||
|
||
describe "Accounts", type: :feature do | ||
let(:user) { create(:admin_user, email: '[email protected]') } | ||
|
||
before do | ||
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(user) | ||
end | ||
|
||
it "shows account info" do | ||
without_partial_double_verification do | ||
allow(Spree::Core::Engine.routes.url_helpers).to receive(:admin_logout_path).and_return('/admin/logout') | ||
end | ||
user = create(:admin_user, email: '[email protected]') | ||
stub_authorization! user | ||
sign_in user | ||
|
||
visit "/admin/account" | ||
|
||
expect(page).to have_content("Logged in as #{user.email}") | ||
expect(page).to have_content("Log out") | ||
expect(page).to have_content(user.email) | ||
expect(current_path).to eq("/admin/users/#{user.id}/edit") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,7 @@ | |
require 'spec_helper' | ||
|
||
describe "Products", type: :feature do | ||
before do | ||
user = create(:admin_user, email: '[email protected]') | ||
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(user) | ||
end | ||
before { sign_in create(:admin_user, email: '[email protected]') } | ||
|
||
it "lists products", :js do | ||
create(:product, name: "Just a product", price: 19.99) | ||
|
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,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidusAdmin | ||
module FeatureHelpers | ||
def sign_in(user) | ||
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(user) | ||
end | ||
|
||
def stub_authorization!(user) | ||
ability = Spree::Ability.new(user) | ||
if block_given? | ||
yield ability | ||
else | ||
ability.can :manage, :all | ||
end | ||
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:current_ability).and_return(ability) | ||
allow_any_instance_of(Spree::Admin::BaseController).to receive(:current_ability).and_return(ability) | ||
end | ||
end | ||
end |