Skip to content

Commit d85ac5c

Browse files
committed
Test space specific logos and footer configuration
1 parent 93f45c5 commit d85ac5c

3 files changed

Lines changed: 124 additions & 39 deletions

File tree

test/controllers/about_controller_test.rb

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class AboutControllerTest < ActionController::TestCase
1515
end
1616

1717
test 'should show correct funder logos in about us and footer' do
18+
plant_space = spaces(:plants)
1819
funder_setting = [
1920
{
2021
url: 'https://example.org/your-funders-website',
@@ -29,9 +30,19 @@ class AboutControllerTest < ActionController::TestCase
2930
url: 'https://example.org/funder-about',
3031
logo: 'https://example.org/funder-about/logo.png',
3132
only: 'about'
33+
},
34+
{
35+
url: 'https://example.org/funder-default-space',
36+
logo: 'https://example.org/funder-default-space/logo.png',
37+
space: 'default'
38+
},
39+
{
40+
url: 'https://example.org/funder-plants-space',
41+
logo: 'https://example.org/funder-plants-space/logo.png',
42+
space: plant_space.host
3243
}
3344
]
34-
45+
3546
with_settings(funders: funder_setting) do
3647
get :us
3748
assert_select '#funding' do
@@ -41,8 +52,13 @@ class AboutControllerTest < ActionController::TestCase
4152
assert_select 'a[href=?]', 'https://example.org/funder-about' do
4253
assert_select 'img[src=?]', 'https://example.org/funder-about/logo.png'
4354
end
55+
assert_select 'a[href=?]', 'https://example.org/funder-default-space' do
56+
assert_select 'img[src=?]', 'https://example.org/funder-default-space/logo.png'
57+
end
4458
assert_select 'a[href=?]', 'https://example.org/funder-footer', count: 0
59+
assert_select 'a[href=?]', 'https://example.org/funder-plants-space', count: 0
4560
assert_select 'img[src=?]', 'https://example.org/funder-footer/logo.png', count: 0
61+
assert_select 'img[src=?]', 'https://example.org/funder-plants-space/logo.png', count: 0
4662
end
4763

4864
assert_select 'footer' do
@@ -52,8 +68,32 @@ class AboutControllerTest < ActionController::TestCase
5268
assert_select 'a[href=?]', 'https://example.org/funder-footer' do
5369
assert_select 'img[src=?]', 'https://example.org/funder-footer/logo.png'
5470
end
71+
assert_select 'a[href=?]', 'https://example.org/funder-default-space' do
72+
assert_select 'img[src=?]', 'https://example.org/funder-default-space/logo.png'
73+
end
5574
assert_select 'a[href=?]', 'https://example.org/funder-about', count: 0
75+
assert_select 'a[href=?]', 'https://example.org/funder-plants-space', count: 0
5676
assert_select 'img[src=?]', 'https://example.org/funder-about/logo.png', count: 0
77+
assert_select 'img[src=?]', 'https://example.org/funder-plants-space/logo.png', count: 0
78+
end
79+
80+
with_host(plant_space.host) do
81+
get :us
82+
assert_select '#funding' do
83+
assert_select 'a[href=?]', 'https://example.org/your-funders-website'
84+
assert_select 'a[href=?]', 'https://example.org/funder-plants-space' do
85+
assert_select 'img[src=?]', 'https://example.org/funder-plants-space/logo.png'
86+
end
87+
assert_select 'a[href=?]', 'https://example.org/funder-default-space', count: 0
88+
end
89+
90+
assert_select 'footer' do
91+
assert_select 'a[href=?]', 'https://example.org/your-funders-website'
92+
assert_select 'a[href=?]', 'https://example.org/funder-plants-space' do
93+
assert_select 'img[src=?]', 'https://example.org/funder-plants-space/logo.png'
94+
end
95+
assert_select 'a[href=?]', 'https://example.org/funder-default-space', count: 0
96+
end
5797
end
5898
end
5999
end

test/controllers/spaces_controller_test.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'test_helper'
22

33
class SpacesControllerTest < ActionController::TestCase
4-
54
include Devise::Test::ControllerHelpers
65
include ActiveJob::TestHelper
76
include ActionMailer::TestHelper
@@ -95,7 +94,7 @@ class SpacesControllerTest < ActionController::TestCase
9594
get :edit, params: { id: @space }
9695
assert_response :success
9796
end
98-
97+
9998
test 'owner should not get edit for other space' do
10099
sign_in @space.user
101100
get :edit, params: { id: spaces(:other) }
@@ -250,17 +249,24 @@ class SpacesControllerTest < ActionController::TestCase
250249
'collections': false,
251250
'content_providers': false,
252251
'trainers': false,
253-
'nodes': false
254-
}
252+
'nodes': false }
255253

256254
with_settings(feature: features) do
257255
get :edit, params: { id: @space }
258256
assert_response :success
259257
assert_select '[name="space[enabled_features][]"]', count: 4 # +1 because of the blank input that allows you to
260-
# clear the list
258+
# clear the list
261259
assert_select '#space_enabled_features_events', count: 1
262260
assert_select '#space_enabled_features_workflows', count: 1
263261
assert_select '#space_enabled_features_materials', count: 0
264262
end
265263
end
264+
265+
test 'space listing adds background-color style for themed space logo' do
266+
@space.update!(theme: 'space')
267+
268+
get :index
269+
assert_response :success
270+
assert_select 'img.space-logo[style*="background-color"]'
271+
end
266272
end

0 commit comments

Comments
 (0)