Sha256: 60625c8237adc4e1f78dd37b94addf50afd8297b3e1d064177cd40806b66ff88

Contents?: true

Size: 1.57 KB

Versions: 7

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'User subscriptions tab', type: :feature do
  stub_authorization!

  let(:user) { create(:user) }

  before do
    allow(Spree.user_class).to receive(:find_by).
      with(hash_including(:id)).
      and_return(user)
  end

  context 'when user has subscriptions' do
    let!(:subscription) {
      create(:subscription,
        actionable_date: '2020-10-21',
        interval_length: 10,
        interval_units: :day,
        user: user)
    }

    before do
      visit '/admin/'
      click_link 'Users'
      click_link subscription.user.email
      within('.tabs') { click_link 'Subscriptions' }
    end

    it 'lists user subscriptions date' do
      subscriptions_table = page.find('#subscriptions-table')

      expect(subscriptions_table).to have_content('2020-10-21')
    end

    it 'lists user subscriptions days' do
      subscriptions_table = page.find('#subscriptions-table')

      expect(subscriptions_table).to have_content('10 days')
    end

    it 'shows edit link to subscriptions' do
      page.find("#subscriptions-table td.actions a.fa-edit").click

      expect(page).to have_current_path spree.edit_admin_subscription_path(subscription), ignore_query: true
    end
  end

  context 'when user does not have subscriptions' do
    it 'displays no found message when user has no subscriptions' do
      visit spree.admin_path
      click_link 'Users'
      click_link user.email
      within('.tabs') { click_link 'Subscriptions' }

      expect(page).to have_content('No Subscriptions found.')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solidus_subscriptions-2.0.2 spec/features/admin_users_subscription_tabs_spec.rb
solidus_subscriptions-2.0.1 spec/features/admin_users_subscription_tabs_spec.rb
solidus_subscriptions-2.0.0 spec/features/admin_users_subscription_tabs_spec.rb
solidus_subscriptions-1.1.0 spec/features/admin_users_subscription_tabs_spec.rb
solidus_subscriptions-1.0.1 spec/features/admin_users_subscription_tabs_spec.rb
solidus_subscriptions-1.0.0 spec/features/admin_users_subscription_tabs_spec.rb
solidus_subscriptions-1.0.0.rc1 spec/features/admin_users_subscription_tabs_spec.rb