Sha256: ddb1d76d53b2105bcc021636dd1cb82cdcdc43035c2d545769c7deb0c6dd00b7

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

# frozen_string_literal: true

module SolidusAdmin
  module TestingSupport
    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

      def find_row(text)
        find('table tbody tr', text:)
      end

      def find_row_checkbox(text)
        find_row(text).find('td:first-child input[type="checkbox"]')
      end

      def select_row(text)
        find_row_checkbox(text).check
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_admin-0.3.2 lib/solidus_admin/testing_support/feature_helpers.rb