-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathdashboard_spec.rb
More file actions
75 lines (56 loc) · 2.01 KB
/
Copy pathdashboard_spec.rb
File metadata and controls
75 lines (56 loc) · 2.01 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# frozen_string_literal: true
RSpec.describe 'Dashboard Page' do
let!(:account) { create(:account) }
let!(:user) { create(:user, account:) }
before do
sign_in(user)
end
context 'when are no templates' do
it 'shows empty state' do
visit root_path
expect(page).to have_link('Create', href: new_template_path)
end
end
context 'when there are templates' do
let!(:authors) { create_list(:user, 5, account:) }
let!(:templates) { authors.map { |author| create(:template, account:, author:) } }
let!(:other_template) { create(:template, account: create(:user).account) }
before do
visit root_path
end
it 'shows the list of templates' do
templates.each do |template|
expect(page).to have_content(template.name)
expect(page).to have_content(template.author.full_name)
end
expect(page).to have_content('Templates')
expect(page).to have_no_content(other_template.name)
expect(page).to have_link('Create', href: new_template_path)
end
it 'shows submission count for templates' do
create(:submission, template: templates[0])
visit root_path
expect(page).to have_content('0')
expect(page).to have_content('1')
end
it 'initializes the template creation process' do
click_link 'Create'
within('#modal') do
fill_in 'template[name]', with: 'New Template'
expect do
click_button 'Create'
end.to change(Template, :count).by(1)
expect(page).to have_current_path(edit_template_path(Template.last), ignore_query: true)
end
end
it 'searches be submitter email' do
submission = create(:submission, :with_submitters, template: templates[0])
submitter = submission.submitters.first
SearchEntries.reindex_all
visit root_path(q: submitter.email)
expect(page).to have_content('Templates not Found')
expect(page).to have_content('Submissions')
expect(page).to have_content(submitter.name)
end
end
end