Module: SolidusAdmin::TestingSupport::FeatureHelpers

Defined in:
lib/solidus_admin/testing_support/feature_helpers.rb

Instance Method Summary collapse

Instance Method Details

#find_row(text) ⇒ Object



21
22
23
# File 'lib/solidus_admin/testing_support/feature_helpers.rb', line 21

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

#find_row_checkbox(text) ⇒ Object



25
26
27
# File 'lib/solidus_admin/testing_support/feature_helpers.rb', line 25

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

#select_row(text) ⇒ Object



29
30
31
# File 'lib/solidus_admin/testing_support/feature_helpers.rb', line 29

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

#sign_in(user) ⇒ Object



6
7
8
# File 'lib/solidus_admin/testing_support/feature_helpers.rb', line 6

def (user)
  allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(user)
end

#stub_authorization!(user) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/solidus_admin/testing_support/feature_helpers.rb', line 10

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