missing redirect? method for pages

did committed Oct 03, 2015
commit ab669699471896d7c42e4b88e1f6467fae0befdb
Showing 2 changed files with 26 additions and 0 deletions
locomotive/steam/entities/page.rb b/lib/locomotive/steam/entities/page.rb +2 -0
@@ @@ -21,6 +21,7 @@ module Locomotive::Steam
raw_template: nil,
source: nil,
editable_elements: {},
+ redirect: false,
redirect_url: {},
redirect_type: nil,
parent_id: nil,
@@ @@ -32,6 +33,7 @@ module Locomotive::Steam
def listed?; !!listed; end
def published?; !!published; end
def templatized?; !!templatized; end
+ def redirect?; redirect.nil? ? redirect_url.present? : redirect; end
def content_type_id
self.target_klass_name =~ Locomotive::Steam::CONTENT_ENTRY_ENGINE_CLASS_NAME
spec/unit/entities/page_spec.rb +24 -0
@@ @@ -53,4 +53,28 @@ describe Locomotive::Steam::Page do
end
end
+ describe '#redirect?' do
+
+ subject { page.redirect? }
+
+ it { is_expected.to eq false }
+
+ context 'redirect_url has been set' do
+
+ let(:attributes) { { redirect: nil, redirect_url: 'http://www.google.fr' } }
+
+ it { is_expected.to eq true }
+
+ context 'but redirect is set to false' do
+
+ let(:attributes) { { redirect: false, redirect_url: 'http://www.google.fr' } }
+
+ it { is_expected.to eq false }
+
+ end
+
+ end
+
+ end
+
end