diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index f7aa5c440..870d7ef55 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -1,4 +1,5 @@ class Admin::DashboardController < Admin::BaseController + layout 'admin' def index end diff --git a/app/controllers/moderation/dashboard_controller.rb b/app/controllers/moderation/dashboard_controller.rb index ceaddd6f4..86196af37 100644 --- a/app/controllers/moderation/dashboard_controller.rb +++ b/app/controllers/moderation/dashboard_controller.rb @@ -1,4 +1,5 @@ class Moderation::DashboardController < Moderation::BaseController + layout 'admin' def index end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb new file mode 100644 index 000000000..f95a14b9f --- /dev/null +++ b/app/helpers/admin_helper.rb @@ -0,0 +1,7 @@ +module AdminHelper + + def namespace + controller.class.parent.name.downcase + end + +end \ No newline at end of file diff --git a/app/views/admin/shared/_menu.html.erb b/app/views/admin/shared/_menu.html.erb new file mode 100644 index 000000000..82c747f2b --- /dev/null +++ b/app/views/admin/shared/_menu.html.erb @@ -0,0 +1,3 @@ +
+ Admin links +
\ No newline at end of file diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 5d9cdb665..ce1f6dd38 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -32,6 +32,7 @@
<%= render 'devise/menu/login_items' %> + <%= render 'shared/admin_login_items' %>
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb new file mode 100644 index 000000000..598ca47fb --- /dev/null +++ b/app/views/layouts/admin.html.erb @@ -0,0 +1,33 @@ + + + + + + + + <%= content_for?(:title) ? yield(:title) : "Admin" %> + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "vendor/modernizr" %> + <%= javascript_include_tag "application", 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + + <%= render 'layouts/header' %> + + <% if notice %> +

<%= notice %>

+ <% end %> + + <% if alert %> +

<%= alert %>

+ <% end %> + +
+ <%= render "/#{namespace}/shared/menu" %> +
+ + <%= yield %> + + + \ No newline at end of file diff --git a/app/views/moderation/shared/_menu.html.erb b/app/views/moderation/shared/_menu.html.erb new file mode 100644 index 000000000..21997abca --- /dev/null +++ b/app/views/moderation/shared/_menu.html.erb @@ -0,0 +1,3 @@ +
+ Moderation links +
\ No newline at end of file diff --git a/app/views/shared/_admin_login_items.html.erb b/app/views/shared/_admin_login_items.html.erb new file mode 100644 index 000000000..e268def4b --- /dev/null +++ b/app/views/shared/_admin_login_items.html.erb @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index b9a946fde..8489fee3d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -12,6 +12,8 @@ en: see_all_debates: See all debates my_account_link: My account language: Site language + administration: Administration + moderation: Moderation footer: copyright: "Ayuntamiento de Madrid, 2015. All rights reserved" debates: diff --git a/config/locales/es.yml b/config/locales/es.yml index 5610b1bf0..44f91be77 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -12,6 +12,8 @@ es: see_all_debates: Ver todos los debates my_account_link: Mi cuenta language: Idioma de la página + administration: Admininstar + moderation: Moderar footer: copyright: "Ayuntamiento de Madrid, %{year}. Todos los derechos reservados" debates: diff --git a/spec/features/admin_spec.rb b/spec/features/admin_spec.rb index a4728623b..1c9e845a0 100644 --- a/spec/features/admin_spec.rb +++ b/spec/features/admin_spec.rb @@ -31,4 +31,50 @@ feature 'Admin' do expect(page).to_not have_content "not authorized" end + scenario "Admin access links" do + create(:administrator, user: user) + + login_as(user) + visit root_path + + expect(page).to have_link('Administration') + expect(page).to_not have_link('Moderator') + end + + scenario "Moderation access links" do + create(:moderator, user: user) + + login_as(user) + visit root_path + + expect(page).to have_link('Moderation') + expect(page).to_not have_link('Administration') + end + + scenario 'Admin dashboard' do + create(:administrator, user: user) + + login_as(user) + visit root_path + + click_link 'Administration' + + expect(current_path).to eq(admin_root_path) + expect(page).to have_css('#admin_menu') + expect(page).to_not have_css('#moderation_menu') + end + + scenario 'Moderation dashboard' do + create(:moderator, user: user) + + login_as(user) + visit root_path + + click_link 'Moderation' + + expect(current_path).to eq(moderation_root_path) + expect(page).to have_css('#moderation_menu') + expect(page).to_not have_css('#admin_menu') + end + end