blob: a3903464b466faa694f937546630e1845b8d1767 (
plain) (
blame)
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
|
require 'rails_helper'
describe ApplicationHelper do
describe 'active_nav_class' do
it 'returns active when on the current page' do
allow(helper).to receive(:current_page?).and_return(true)
result = helper.active_nav_class("/test")
expect(result).to eq "active"
end
it 'returns empty string when not on current page' do
allow(helper).to receive(:current_page?).and_return(false)
result = helper.active_nav_class("/test")
expect(result).to eq ""
end
end
describe 'add_rtl_body_class' do
it 'adds rtl body class if locale is Arabic' do
I18n.locale = :ar
expect(helper.add_rtl_body_class('other classes')).to eq 'other classes rtl'
end
it 'adds rtl body class if locale is Farsi' do
I18n.locale = :fa
expect(helper.add_rtl_body_class('other classes')).to eq 'other classes rtl'
end
it 'adds rtl if locale is Hebrew' do
I18n.locale = :he
expect(helper.add_rtl_body_class('other classes')).to eq 'other classes rtl'
end
it 'does not add rtl if locale is Thai' do
I18n.locale = :th
expect(helper.add_rtl_body_class('other classes')).to eq 'other classes'
end
end
describe 'fa_icon' do
it 'returns a tag of fixed-width cog' do
expect(helper.fa_icon('cog fw')).to eq '<i class="fa fa-cog fa-fw"></i>'
end
end
describe 'favicon_path' do
it 'returns /favicon.ico on production enviromnent' do
expect(Rails.env).to receive(:production?).and_return(true)
expect(helper.favicon_path).to eq '/favicon.ico'
end
end
describe 'open_registrations?' do
it 'returns true when open for registrations' do
without_partial_double_verification do
expect(Setting).to receive(:open_registrations).and_return(true)
end
expect(helper.open_registrations?).to eq true
end
it 'returns false when closed for registrations' do
without_partial_double_verification do
expect(Setting).to receive(:open_registrations).and_return(false)
end
expect(helper.open_registrations?).to eq false
end
end
describe 'show_landing_strip?', without_verify_partial_doubles: true do
describe 'when signed in' do
before do
allow(helper).to receive(:user_signed_in?).and_return(true)
end
it 'does not show landing strip' do
expect(helper.show_landing_strip?).to eq false
end
end
describe 'when signed out' do
before do
allow(helper).to receive(:user_signed_in?).and_return(false)
end
it 'does not show landing strip on single user instance' do
allow(helper).to receive(:single_user_mode?).and_return(true)
expect(helper.show_landing_strip?).to eq false
end
it 'shows landing strip on multi user instance' do
allow(helper).to receive(:single_user_mode?).and_return(false)
expect(helper.show_landing_strip?).to eq true
end
end
end
describe 'title' do
it 'returns site title on production enviroment' do
Setting.site_title = 'site title'
expect(Rails.env).to receive(:production?).and_return(true)
expect(helper.title).to eq 'site title'
end
end
end
|