Sha256: 4c985535eb333e7da4a73dd6eb5644b063e7507d83ee0496092e1c3f62dbda59

Contents?: true

Size: 1.69 KB

Versions: 28

Compression:

Stored size: 1.69 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class SegmentOverridesIntegrationTest < Workarea::IntegrationTest
      include Storefront::IntegrationTest

      def test_admins_ignore_segments
        create_life_cycle_segments
        first_time_visitor = Segment::FirstTimeVisitor.instance
        returning_visitor = Segment::ReturningVisitor.instance
        product = create_product(active: true, active_segment_ids: [returning_visitor.id])
        content = Content.for('home_page')
        content.blocks.create!(
          type: 'html',
          data: { 'html' => '<p>Foo</p>' },
          active_segment_ids: [returning_visitor.id]
        )

        set_current_user(create_user(admin: true))

        get storefront.search_path(q: '*')
        refute_includes(response.body, product.id)

        get storefront.root_path
        refute_includes(response.body, '<p>Foo</p>')
      end

      def test_impersonation_segments
        create_life_cycle_segments
        first_time_visitor = Segment::FirstTimeVisitor.instance
        customer = create_user
        super_admin = create_user(password: 'W3bl1nc!', super_admin: true)
        post storefront.login_path, params: { email: super_admin.email, password: 'W3bl1nc!' }
        post admin.impersonations_path, params: { user_id: customer.id }

        get storefront.current_user_path(format: 'json')
        assert(response.headers['X-Workarea-Segments'].blank?)

        post admin.segment_override_path,
          params: { segment_ids: { first_time_visitor.id => 'true' } }

        get storefront.current_user_path(format: 'json')
        assert_equal(first_time_visitor.id, response.headers['X-Workarea-Segments'])
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-storefront-3.5.27 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.26 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.25 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.23 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.22 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.21 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.20 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.19 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.18 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.17 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.16 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.15 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.14 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.13 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.12 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.11 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.10 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.9 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.8 test/integration/workarea/storefront/segment_overrides_integration_test.rb
workarea-storefront-3.5.7 test/integration/workarea/storefront/segment_overrides_integration_test.rb