spec/models/locomotive/page_spec.rb in locomotivecms-3.0.0.pre.beta.1 vs spec/models/locomotive/page_spec.rb in locomotivecms-3.0.0.rc1
- old
+ new
@@ -13,18 +13,22 @@
expect(build(:page)).to be_valid
end
describe 'validation' do
- %w{site title}.each do |field|
- it "requires the presence of the #{field}" do
- page = build(:page, field.to_sym => nil)
- expect(page).to_not be_valid
- expect(page.errors[field.to_sym]).to eq(["can't be blank"])
- end
+ it 'requires the presence of a site' do
+ page = build(:page, site: nil)
+ expect(page).to_not be_valid
+ expect(page.errors[:site]).to eq(["can't be blank"])
end
+ it 'requires the presence of a title' do
+ page = build(:page, title: nil, site: build(:site))
+ expect(page).to_not be_valid
+ expect(page.errors[:title]).to eq(["can't be blank"])
+ end
+
it 'requires the presence of the slug' do
page = build(:page, title: nil, slug: nil)
expect(page).to_not be_valid
expect(page.errors[:slug]).to eq(["can't be blank"])
end
@@ -119,13 +123,13 @@
page = build(:page, slug: ' convention_Valid ité.html ')
page.valid?
expect(page.slug).to eq('convention_valid_ite_dot_html')
end
- it 'has no cache strategy' do
+ it 'has cache enabled' do
page = build(:page, site: nil)
- expect(page.with_cache?).to eq(false)
+ expect(page.cache_enabled?).to eq(true)
end
end
describe 'localizing slugs and fullpaths' do
@@ -421,9 +425,29 @@
end
it 'can also be a JSON document' do
@page.response_type = 'application/json'
expect(@page.default_response_type?).to eq(false)
+ end
+
+ end
+
+ it_should_behave_like 'model scoped by a site' do
+
+ let(:model) { create(:page) }
+ let(:attribute) { :content_version }
+
+ describe 'the raw_template has been modified' do
+
+ let(:date) { Time.zone.local(2015, 4, 1, 12, 0, 0) }
+
+ it 'updates the template_version attribute of the site' do
+ model.raw_template = 'new one'
+ Timecop.freeze(date) do
+ expect { model.save! }.to change { site.template_version }.to date
+ end
+ end
+
end
end
class Foo