Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/locomotive/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def update
def destroy
authorize @page
service.destroy(@page)
respond_with @page, location: edit_content_path(current_site.pages.root.first)
respond_with @page, location: edit_content_path(current_site.pages.home.first)
end

def sort
Expand Down
2 changes: 1 addition & 1 deletion app/models/locomotive/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Page

## named scopes ##
scope :latest_updated, -> { order_by(updated_at: :desc).limit(Locomotive.config.ui[:latest_entries_nb]) }
scope :root, -> { where(slug: 'index', depth: 0) }
scope :home, -> { where(slug: 'index', depth: 0) }
scope :not_found, -> { where(slug: '404', depth: 0) }
scope :published, -> { where(published: true) }
scope :fullpath, ->(fullpath) { where(fullpath: fullpath) }
Expand Down
2 changes: 1 addition & 1 deletion app/models/locomotive/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def create_default_pages!

def destroy_pages
# pages is a tree so we just need to delete the root (as well as the page not found page)
self.pages.root.first.try(:destroy) && self.pages.not_found.first.try(:destroy)
self.pages.home.first.try(:destroy) && self.pages.not_found.first.try(:destroy)
end

end
Expand Down
4 changes: 3 additions & 1 deletion app/services/locomotive/page_tree_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def pages_with_minimun_attributes
site.pages.unscoped.
minimal_attributes.
order_by_depth_and_position.
to_a
to_a.tap do |pages|
Rails.logger.debug "*** pages = #{pages.first.inspect}"
end
end

#:nodoc:
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/locomotive/pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let!(:membership) do
create(:membership, account: account, site: site, role: 'admin')
end
let(:page) { site.pages.root.first }
let(:page) { site.pages.home.first }

before do
request_site site
Expand All @@ -27,7 +27,7 @@

describe "#POST create" do
let(:page_attributes) do
attributes_for(:sub_page, parent_id: site.pages.root.first._id, raw_template: 'Hello world')
attributes_for(:sub_page, parent_id: site.pages.home.first._id, raw_template: 'Hello world')
end
subject do
post :create, params: { site_handle: site, locale: :en, page: page_attributes }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

trait :index do
after(:build) do |page, evaluator|
page.parent = page.site.pages.root.first
page.parent = page.site.pages.home.first
page.raw_template = nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/locomotive/pages_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

context 'index page' do

let(:page) { current_site.pages.root.first }
let(:page) { current_site.pages.home.first }
it { is_expected.to eq false }

end
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/locomotive/shared/pages_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

describe '#localized_preview_page_paths' do

let(:page) { current_site.pages.root.first }
let(:page) { current_site.pages.home.first }

subject { localized_preview_page_paths(page, mounted_on: mounted_on) }

Expand Down
4 changes: 2 additions & 2 deletions spec/models/locomotive/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

it 'requires the uniqueness of the slug within a "folder"' do
site = create(:site)
root = site.pages.root.first
root = site.pages.home.first
child_1 = create(:page, slug: 'first_child', parent: root, site: site)
page = build(:page, slug: 'first_child', parent: root, site: site)
expect(page).to_not be_valid
Expand Down Expand Up @@ -157,7 +157,7 @@
describe 'tree organization' do

let!(:site) { create(:site) }
let(:home) { site.pages.root.first }
let(:home) { site.pages.home.first }
let(:child_1) { create(:page, title: 'Subpage 1', slug: 'foo', parent: home) }

it 'adds root elements' do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/json_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

before do
page = site.pages.create(
parent: site.pages.root.first,
parent: site.pages.home.first,
title: 'Post form',
slug: 'post-form',
response_type: 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion spec/services/locomotive/editable_element_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Locomotive::EditableElementService do

let(:site) { create(:site) }
let(:home) { site.pages.root.first }
let(:home) { site.pages.home.first }
let(:account) { create(:account) }
let(:locale) { :en }
let(:service) { described_class.new(site, account, locale) }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/locomotive/page_parsing_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Locomotive::PageParsingService do

let(:site) { create(:site) }
let(:home) { site.pages.root.first }
let(:home) { site.pages.home.first }
let(:service) { described_class.new(site, :en) }

describe '#find_all_elements' do
Expand Down
9 changes: 4 additions & 5 deletions spec/services/locomotive/page_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

describe '#create' do

subject { service.create(title: 'Hello world', parent: site.pages.root.first) }
subject { service.create(title: 'Hello world', parent: site.pages.home.first) }

it { expect { subject }.to change { Locomotive::Page.count }.by 1 }

Expand All @@ -19,7 +19,7 @@

describe '#update' do

let(:page) { site.pages.root.first }
let(:page) { site.pages.home.first }

subject { service.update(page, title: 'My new home page') }

Expand All @@ -39,7 +39,7 @@

context 'index page' do

subject { site.pages.root.first }
subject { site.pages.home.first }

it 'sets a nice default title, the slug and the fullpath' do
expect(subject.title_translations).to eq('en' => 'Home page', 'fr' => "Page d'accueil")
Expand Down Expand Up @@ -115,7 +115,7 @@

context 'index page' do

subject { site.pages.root.first }
subject { site.pages.home.first }

it 'sets a nice default title, the slug and the fullpath' do
expect(subject.title_translations).to eq('en' => 'Home page', 'fr' => "Page d'accueil")
Expand All @@ -125,7 +125,6 @@
end

end

end

end
4 changes: 2 additions & 2 deletions spec/support/features/site_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def create_full_site
create(:section, :gallery, site: @site) # Gallery of images

# 4. create pages
@site.pages.create(parent: @site.pages.root.first, title: 'Contact', slug: 'contact', raw_template: %{<html><body>{% if message.errors %}num errors: {{ message.errors.size }} / {% for error in message.errors %}-{{error[0]}} {{error[1]}}-{% endfor %}{% endif %}{% model_form 'messages', success: '/', error: '/contact' %}<input type="text" name="content[name]" value="{{customer_message.name}}"><input type="text" name="content[message]" value="{{customer_message.message}}"><input type="submit" value="Send">{% endmodel_form %}</body></html>})
@site.pages.create(parent: @site.pages.home.first, title: 'Contact', slug: 'contact', raw_template: %{<html><body>{% if message.errors %}num errors: {{ message.errors.size }} / {% for error in message.errors %}-{{error[0]}} {{error[1]}}-{% endfor %}{% endif %}{% model_form 'messages', success: '/', error: '/contact' %}<input type="text" name="content[name]" value="{{customer_message.name}}"><input type="text" name="content[message]" value="{{customer_message.message}}"><input type="submit" value="Send">{% endmodel_form %}</body></html>})
@site.pages.create(
parent: @site.pages.root.first,
parent: @site.pages.home.first,
title: 'Hello world',
slug: 'hello-world',
raw_template: %{<html><body>{% section 'header' %} {% section 'gallery' %}</body></html>},
Expand Down
4 changes: 2 additions & 2 deletions spec/system/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
var entry = createEntry('messages', { name: 'John', message: 'Hello world' });
setProp("message", entry.name + ' sends ' + entry.message);
JS
@site.pages.create(parent: @site.pages.root.first, title: 'Action call', slug: 'action', raw_template: %{<html><body>{% action "create message" %}#{javascript}{% endaction %}{{ message }}</body></html>})
@site.pages.create(parent: @site.pages.home.first, title: 'Action call', slug: 'action', raw_template: %{<html><body>{% action "create message" %}#{javascript}{% endaction %}{{ message }}</body></html>})
end

it 'executes the action' do
Expand All @@ -30,7 +30,7 @@
var entry = updateEntry('messages', 'john', { message: 'Hello world!' });
setProp("message", entry.name + ' sends ' + entry.message);
JS
@site.pages.create(parent: @site.pages.root.first, title: 'Action call', slug: 'action', raw_template: %{<html><body>{% action "create message" %}#{javascript}{% endaction %}{{ message }}</body></html>})
@site.pages.create(parent: @site.pages.home.first, title: 'Action call', slug: 'action', raw_template: %{<html><body>{% action "create message" %}#{javascript}{% endaction %}{{ message }}</body></html>})
end

it 'executes the action' do
Expand Down