nocms-blocks 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/README.md +7 -3
- data/app/models/no_cms/blocks/block.rb +31 -128
- data/app/models/no_cms/blocks/concerns/serializing_fields.rb +386 -0
- data/app/models/no_cms/blocks/layout.rb +98 -0
- data/app/views/no_cms/blocks/blocks/_default.html.erb +6 -0
- data/db/migrate/20150709132202_add_non_translated_fields_info_to_no_cms_blocks_block.rb +5 -0
- data/db/migrate/20150710112549_move_layout_from_no_cms_blocks_block_translations_to_no_cms_blocks_blocks.rb +19 -0
- data/lib/generators/nocms/templates/config/initializers/nocms/blocks.rb +8 -0
- data/lib/no_cms/blocks/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +3 -2
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +163 -0
- data/spec/dummy/log/test.log +94024 -0
- data/spec/dummy/public/uploads/test_image/logo/2/logo.png +0 -0
- data/spec/dummy/public/uploads/test_image/logo/2/logo2.png +0 -0
- data/spec/dummy/public/uploads/test_image/logo/3/logo.png +0 -0
- data/spec/dummy/public/uploads/test_image/logo/4/logo.png +0 -0
- data/spec/dummy/public/uploads/test_image/logo/5/logo.png +0 -0
- data/spec/dummy/public/uploads/test_image/logo/6/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-1395/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-1590/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-1891/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-1891/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-2425/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-3650/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-3867/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-3867/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-5629/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-5795/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-5882/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194769-17662-9375/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-0450/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-0733/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-0733/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-1087/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-1087/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-1788/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-2101/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-4443/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-5065/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-6456/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-8131/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194790-17727-9096/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194856-17785-0815/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194856-17785-4789/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194856-17785-7685/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-0259/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-0349/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-0476/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-1997/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-3813/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-3813/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-4455/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-5316/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-5316/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-7121/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-7447/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-7677/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-8037/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194857-17785-8791/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194878-17844-1352/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194878-17844-1557/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194878-17844-5177/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194878-17844-5338/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194878-17844-8747/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-3191/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-3986/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-5951/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-6104/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-7114/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-7114/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-7617/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-8185/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-8495/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-8495/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-8991/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194879-17844-9466/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194892-17862-1771/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436194926-17904-9747/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195033-17981-2265/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195045-18015-3603/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195085-18055-8412/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195101-18097-0044/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195126-18165-6939/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195152-18225-1850/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195169-18262-2283/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195186-18300-3395/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195205-18336-0453/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195242-18389-3554/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195255-18420-9336/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195745-18605-6163/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195823-18669-7443/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195886-18739-5334/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195900-18776-9749/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436195935-18824-1992/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436196060-18894-4158/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436196106-18943-1035/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436196156-18987-1445/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436196187-19045-9003/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436196275-19125-3257/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436196321-19169-5591/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-0160/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-0565/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-1519/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-2202/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-2400/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-2928/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-3260/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-4333/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-5122/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-6333/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-6333/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-7928/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-9359/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-9392/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-9549/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-9549/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258374-8961-9648/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258382-8967-0797/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258453-9165-7375/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258549-9282-2039/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258623-9355-6670/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436258674-9394-2929/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436264869-10860-2169/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436276653-16968-2375/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436276734-17282-9777/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436276770-17431-4333/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436276781-17463-5971/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436276875-17556-1972/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436276882-17588-9186/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436276896-17657-9942/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436277157-17795-9344/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436277178-17833-8883/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436277781-18431-2830/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436278571-18860-1079/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436282613-22892-0135/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436282638-22953-7833/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436282887-23026-0068/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436282978-23160-8886/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-1740/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-3170/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-3501/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-6393/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-6862/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-7741/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-8051/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-8064/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-8093/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436284256-24634-9497/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-0200/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-0325/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-1380/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-4150/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-4347/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-5072/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-5891/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-6304/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-6620/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-6703/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-8254/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436553862-9485-8313/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-0021/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-1865/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-2510/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-3771/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-4441/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-5712/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-6456/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-6520/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-8183/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-8675/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-8953/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554155-9646-9271/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554181-9685-7099/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554233-9708-0769/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554254-9739-7026/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554350-9834-3927/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554416-9875-0666/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554519-9921-2596/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554569-9980-0004/logo.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554694-10292-1775/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554694-10292-5549/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554722-10308-2875/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554732-10340-8854/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436554994-10463-9859/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436555134-10554-3506/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436555227-10604-7612/logo2.png +0 -0
- data/spec/dummy/public/uploads/tmp/1436555450-10700-1633/logo2.png +0 -0
- data/spec/models/no_cms/blocks/duplicating_blocks_spec.rb +161 -0
- data/spec/models/no_cms/blocks/i18n_blocks_spec.rb +101 -0
- data/spec/models/no_cms/blocks/layout_spec.rb +125 -0
- data/spec/spec_helper.rb +3 -0
- metadata +385 -5
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,161 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NoCms::Blocks::Block do
|
4
|
+
|
5
|
+
context "when duplicating a block without translations" do
|
6
|
+
|
7
|
+
let(:block_title) { Faker::Lorem.sentence }
|
8
|
+
let(:image_attributes) { }
|
9
|
+
let(:block) do
|
10
|
+
NoCms::Blocks::Block.create layout: 'title-long_text',
|
11
|
+
title: block_title,
|
12
|
+
body: Faker::Lorem.paragraph,
|
13
|
+
logo: attributes_for(:test_image),
|
14
|
+
background: attributes_for(:test_image),
|
15
|
+
header: attributes_for(:test_image)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
let(:dupped_block) { block.dup }
|
20
|
+
|
21
|
+
|
22
|
+
before(:all) do
|
23
|
+
NoCms::Blocks.configure do |config|
|
24
|
+
config.block_layouts = {
|
25
|
+
'title-long_text' => {
|
26
|
+
template: 'title-long_text',
|
27
|
+
fields: {
|
28
|
+
title: { type: :string, translated: false },
|
29
|
+
body: { type: :text, translated: false, duplicate: :nullify },
|
30
|
+
logo: { type: TestImage, translated: false, duplicate: :dup },
|
31
|
+
background: { type: TestImage, translated: false, duplicate: :nil },
|
32
|
+
header: { type: TestImage, translated: false, duplicate: :link }
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
before { dupped_block.save! }
|
40
|
+
|
41
|
+
subject { NoCms::Blocks::Block.find dupped_block.id }
|
42
|
+
|
43
|
+
it "should have the same layout" do
|
44
|
+
expect(subject.layout).to eq block.layout
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have the same text" do
|
48
|
+
expect(subject.title).to eq block_title
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should nullify the field configured to be nullified" do
|
52
|
+
expect(subject.body).to be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should duplicate an Active Record field configured to be duplicated" do
|
56
|
+
expect(subject.logo).to_not be_new_record
|
57
|
+
expect(subject.logo).to_not eq block.logo
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return a new record when an AR field is configured to nullify" do
|
61
|
+
expect(subject.background).to be_new_record
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should link an Active Record field configured to be linked" do
|
65
|
+
expect(subject.header).to eq block.header
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when duplicating a block with translations" do
|
71
|
+
|
72
|
+
let(:block_title_es) { Faker::Lorem.sentence }
|
73
|
+
let(:block_title_en) { Faker::Lorem.sentence }
|
74
|
+
let(:block) do
|
75
|
+
NoCms::Blocks::Block.create layout: 'title-long_text',
|
76
|
+
logo: attributes_for(:test_image),
|
77
|
+
background: attributes_for(:test_image),
|
78
|
+
header: attributes_for(:test_image),
|
79
|
+
translations_attributes: [
|
80
|
+
{
|
81
|
+
locale: 'es',
|
82
|
+
title: block_title_es,
|
83
|
+
body: Faker::Lorem.paragraph,
|
84
|
+
logo: attributes_for(:test_image),
|
85
|
+
background: attributes_for(:test_image),
|
86
|
+
header: attributes_for(:test_image)
|
87
|
+
},
|
88
|
+
{
|
89
|
+
locale: 'en',
|
90
|
+
title: block_title_en,
|
91
|
+
body: Faker::Lorem.paragraph,
|
92
|
+
logo: attributes_for(:test_image),
|
93
|
+
background: attributes_for(:test_image),
|
94
|
+
header: attributes_for(:test_image)
|
95
|
+
}
|
96
|
+
]
|
97
|
+
end
|
98
|
+
|
99
|
+
let(:dupped_block) { block.dup }
|
100
|
+
|
101
|
+
|
102
|
+
before(:all) do
|
103
|
+
NoCms::Blocks.configure do |config|
|
104
|
+
config.block_layouts = {
|
105
|
+
'title-long_text' => {
|
106
|
+
template: 'title-long_text',
|
107
|
+
fields: {
|
108
|
+
title: :string,
|
109
|
+
description: { type: :string, translated: false },
|
110
|
+
body: { type: :text, duplicate: :nullify },
|
111
|
+
logo: { type: TestImage, duplicate: :dup },
|
112
|
+
background: { type: TestImage, duplicate: :nil },
|
113
|
+
header: { type: TestImage, duplicate: :link }
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
before { dupped_block.save! }
|
121
|
+
|
122
|
+
subject { NoCms::Blocks::Block.find dupped_block.id }
|
123
|
+
|
124
|
+
it "should have the same layout" do
|
125
|
+
expect(subject.layout).to eq block.layout
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should have the same text" do
|
129
|
+
[:es, :en].each do |locale|
|
130
|
+
I18n.with_locale(locale) { expect(subject.title).to eq send("block_title_#{locale}") }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should nullify the field configured to be nullified" do
|
135
|
+
[:es, :en].each do |locale|
|
136
|
+
I18n.with_locale(locale) { expect(subject.body).to be_nil }
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should duplicate an Active Record field configured to be duplicated" do
|
141
|
+
[:es, :en].each do |locale|
|
142
|
+
expect(subject.logo).to_not be_new_record
|
143
|
+
expect(subject.logo).to_not eq block.logo
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should return a new record when an AR field is configured to nullify" do
|
148
|
+
[:es, :en].each do |locale|
|
149
|
+
expect(subject.background).to be_new_record
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should link an Active Record field configured to be linked" do
|
154
|
+
[:es, :en].each do |locale|
|
155
|
+
expect(subject.header).to eq block.header
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|