-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathconfiguration_spec.rb
More file actions
166 lines (125 loc) · 4.9 KB
/
configuration_spec.rb
File metadata and controls
166 lines (125 loc) · 4.9 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
require 'rails_helper'
include ActionView::Helpers::SanitizeHelper
feature "Website Configuration" do
let(:event) { create(:event) }
let(:organizer) { create(:organizer, event: event) }
scenario "Organizer creates a new website for event" do
login_as(organizer)
visit event_path(event)
within('.navbar') { click_on("Website") }
click_on("Save")
expect(page).to have_content("Website was successfully created")
expect(event.website).to be_present
end
scenario "Organizer configures domain for an existing website for event", :js do
website = create(:website, event: event)
home_page = create(:page, website: website)
with_domain('lvh.me') do
visit("/#{home_page.slug}")
expect(current_path).to eq(not_found_path)
end
login_as(organizer)
visit event_path(website.event)
within('.navbar') { click_on("Website") }
expect(page).to have_content("Edit Website")
fill_in('Domains', with: 'lvh.me')
fill_in('Navigation links', with: "Home\n")
click_on("Save")
expect(page).to have_content("Website was successfully updated")
logout
with_domain('lvh.me') do
visit("/#{home_page.slug}")
expect(page).to have_content(strip_tags(home_page.published_body))
click_on(home_page.name, match: :first)
expect(current_path).to eq("/#{home_page.slug}")
end
end
scenario "Organizer fails to add font file correctly", :js do
website = create(:website, event: event)
login_as(organizer)
visit edit_event_staff_website_path(event)
click_on("Add Font")
click_on("Save")
expect(page).to have_content("Website was successfully updated")
expect(website.fonts.count).to eq(0)
click_on("Add Font")
within(".nested-fonts") { fill_in("Name", with: "Times") }
click_on("Save")
expect(page).to have_content("There were errors updating your website configuration")
within(".nested-fonts") { expect(page).to have_content("can't be blank") }
end
scenario "Organizer configures tailwind with head content", :js do
website = create(:website, event: event)
home_page = create(:page, website: website)
login_as(organizer)
visit edit_event_staff_website_path(event)
click_on("Add Content")
fill_in_codemirror(<<~HTML
<script>
tailwind.config = {
theme: {
extend: {
colors: {
clifford: '#da373d',
}
}
}
}
</script>
HTML
)
fill_in("City", with: "Big Red")
click_on("Save")
visit edit_event_staff_page_path(event, home_page)
fill_in_codemirror(
'<div class="text-clifford" id="red-dog">Clifford The Big Red Dog</div>'
)
click_on("Save")
accept_confirm { click_on("Publish") }
click_on("View")
expect(computed_style("#red-dog", "color")).to eq("rgb(218, 55, 61)")
end
scenario "Organizer adjusts website caching", :caching do
fastly_service = spy("fastly_service")
allow(FastlyService).to receive(:service).and_return fastly_service
website = create(:website, event: event)
home_page = create(:page, website: website, published_body: 'Home Content')
visit page_path(event, home_page)
expect(response_headers["Cache-Control"]).to eq("max-age=0, private, s-maxage=0")
login_as(organizer)
visit edit_event_staff_website_path(event)
select("automatic", from: "Caching")
click_on("Save")
visit page_path(event, home_page)
expect(response_headers["Cache-Control"]).to eq("max-age=0, public, s-maxage=604800")
expect(response_headers["Surrogate-Key"]).to eq(event.slug)
last_modified = response_headers["Last-Modified"]
visit page_path(event, home_page)
expect(response_headers["Last-Modified"]).to eq(last_modified)
RSpec::Mocks.space.proxy_for(fastly_service).reset
sleep 1
visit event_staff_pages_path(event)
click_on("Publish")
expect(fastly_service).to have_received(:purge_by_key).with(event.slug)
visit page_path(event, home_page)
expect(response_headers["Last-Modified"]).not_to eq(last_modified)
visit edit_event_staff_website_path(event)
select("manual", from: "Caching")
click_on("Save")
visit page_path(event, home_page)
expect(response_headers["Cache-Control"]).to eq("max-age=0, public, s-maxage=604800")
expect(response_headers["Surrogate-Key"]).to eq(event.slug)
last_modified = response_headers["Last-Modified"]
RSpec::Mocks.space.proxy_for(fastly_service).reset
sleep 1
visit event_staff_pages_path(event)
click_on("Publish")
expect(fastly_service).not_to have_received(:purge_by_key).with(event.slug)
visit page_path(event, home_page)
expect(response_headers["Last-Modified"]).to eq(last_modified)
visit edit_event_staff_website_path(event)
click_on("Purge")
visit page_path(event, home_page)
expect(response_headers["Last-Modified"]).not_to eq(last_modified)
end
end