-
Notifications
You must be signed in to change notification settings - Fork 617
Expand file tree
/
Copy pathindex_spec.rb
More file actions
87 lines (63 loc) · 2.67 KB
/
index_spec.rb
File metadata and controls
87 lines (63 loc) · 2.67 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
describe 'locomotive/current_site_metafields/index', type: :view do
helper(Locomotive::BaseHelper, Locomotive::Shared::AccountsHelper, Locomotive::Shared::SitesHelper, Locomotive::Shared::SiteMetafieldsHelper, Locomotive::CurrentSiteMetafieldsHelper, Locomotive::Engine.routes.url_helpers)
helper(Locomotive::TestViewHelpers)
let(:schema) { [] }
let(:site) { create('test site', metafields_schema: schema) }
before do
allow(view).to receive(:current_site).and_return(site)
allow(view).to receive(:current_locomotive_account).and_return(site.memberships.first.account)
assign(:site, site)
end
subject { render }
describe 'no metafields schema' do
it 'does not render the tab about the locales' do
expect(subject).to include('There are no metafields defined for your site.')
end
end
describe 'namespace' do
let(:schema) { [
{ 'name' => 'theme', 'fields' => [{ 'name' => 'background_color'}], 'position' => 1 },
{ 'name' => 'shop', 'label' => 'My shop', 'fields' => [{ 'name' => 'address'}], 'position' => 0 }
] }
it 'renders the tabs with namespaces' do
expect(subject).to include('My shop')
expect(subject).to include('Theme')
expect(subject.index('My shop')).to be < subject.index('Theme')
end
end
describe 'fields' do
let(:schema) { [
{ 'name' => 'shop', 'label' => 'My shop', 'fields' => [
{ 'name' => 'address', 'hint' => 'My address goes here' }, { 'name' => 'city', 'label' => 'My city' }, { 'name' => 'zip_code' }, { 'name' => 'icon', 'type' => 'image' }
], 'position' => 0 } ] }
it 'renders the fields' do
expect(subject).to include('>Address</label>')
expect(subject).to include('>My city</label>')
expect(subject).to include('>Zip code</label>')
expect(subject).to include('>My address goes here</span>')
end
describe 'select field type' do
let(:schema) { [
{ 'name' => 'theme', 'fields' => [
{ 'name' => 'color', 'type' => 'select', 'select_options' => { 'blue' => { 'en' => 'Blue color' }, 'red' => { 'en' => 'Red color' } } }
] }] }
it 'renders the options' do
expect(subject).to include('<option value="blue">Blue color</option>')
expect(subject).to include('<option value="red">Red color</option>')
end
end
describe 'raw text field type' do
let(:schema) { [
{
'name' => 'theme',
'fields' => [
{ 'name' => 'footer_scripts', 'type' => 'text', 'format' => 'raw' }
]
}
] }
it 'does not render wsiwyg editor' do
expect(subject).not_to include('wysihtml5-editor')
end
end
end
end