blob: f42123f43a87616aff762b22b446353449318c9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
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' do
subscriptions_table = page.find('#subscriptions-table')
expect(subscriptions_table).to have_content('2020-10-21')
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
|