Skip to content

Commit

Permalink
Merge 60e2cb5 into dcd8b46
Browse files Browse the repository at this point in the history
  • Loading branch information
duarme committed Jan 2, 2015
2 parents dcd8b46 + 60e2cb5 commit 9ce78b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
7 changes: 7 additions & 0 deletions core/app/helpers/refinery/site_bar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ def site_bar_switch_link
end
end

def site_bar_edit_link
return nil if admin? || @page.nil?
link_to t('refinery.admin.pages.edit', site_bar_translate_locale_args),
refinery.admin_edit_page_path(@page.nested_url,
:switch_locale => (@page.translations.first.locale unless @page.translated_to_default_locale?))
end

def site_bar_translate_locale_args
{ :locale => Refinery::I18n.current_locale }
end
Expand Down
1 change: 1 addition & 0 deletions core/app/views/refinery/_site_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<div id='site_bar_content' class='clearfix'>
<div id='editor_switch'>
<%= site_bar_switch_link -%>
<%= site_bar_edit_link -%>
</div>
<%= link_to image_tag("refinery/logo-site-bar.png", :alt => "Refinery CMS™"),
'http://refinerycms.com',
Expand Down
20 changes: 11 additions & 9 deletions core/spec/features/refinery/site_bar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Refinery
describe "site bar", :type => :feature do
refinery_login_with :refinery_user

it "have logout link" do
it "has a logout link" do
visit Refinery::Core.backend_path

expect(page).to have_content("Log out")
Expand All @@ -14,7 +14,7 @@ module Refinery
context "when in backend" do
before { visit Refinery::Core.backend_path }

it "have a 'switch to your website button'" do
it "has a 'switch to your website button'" do
expect(page).to have_content("Switch to your website")
expect(page).to have_selector("a[href='/']")
end
Expand All @@ -27,14 +27,11 @@ module Refinery
end

context "when in frontend" do
before do
# make a page in order to avoid 404
FactoryGirl.create(:page, :link_url => "/")
# make a page in order to avoid 404
let!(:root_page) { FactoryGirl.create(:page, :link_url => "/") }
before { visit refinery.root_path }

visit refinery.root_path
end

it "have a 'switch to your website editor' button" do
it "has a 'switch to your website editor' button" do
expect(page).to have_content("Switch to your website editor")
expect(page).to have_selector("a[href='/refinery']")
end
Expand All @@ -44,6 +41,11 @@ module Refinery
click_link "Switch to your website editor"
expect(page.current_path).to match(/\A#{Refinery::Core.backend_path}/)
end

it "has an 'edit this page' button" do
expect(page).to have_link("Edit this page", :href => refinery.edit_admin_page_path(root_page))
end

end
end
end

0 comments on commit 9ce78b8

Please sign in to comment.