Commit bf1ee6a7 authored by Alexandre Friquet's avatar Alexandre Friquet
Browse files

Fixed menus displayed and all tests are green: refs #27.

parent 8e118f6e
......@@ -51,6 +51,7 @@ body #page {
font-size: 90%;
font-weight: 600;
margin: 0 0 0.5em;
text-transform: uppercase;
}
a {
......
......@@ -25,7 +25,7 @@ class Menu < ActiveRecord::Base
acts_as_list
attr_accessible :title
attr_accessible :title, :uid
default_scope :order => "position ASC"
......@@ -54,4 +54,8 @@ class Menu < ActiveRecord::Base
where("title NOT LIKE ?", "Pied de page")
end
def destroyable?
!uid.present?
end
end
......@@ -22,61 +22,66 @@
%>
<nav id="main-nav" role="navigation">
<ul id="menus">
<%= menu_to "Accueil", root_path, class: 'menu_item' %>
<%= menu_to "Calendrier", calendar_path(year: Time.now.year, month: Time.now.month), class: 'menu_item' %>
<li class="menu_item">
<span class="menu_title">LETTRES D'INFORMATION</span>
<ul>
<% Newsletter.for_nav.each do |newsletter| %>
<%= menu_to newsletter.title, newsletter %>
<% end %>
<%= menu_to "Archives", newsletters_path %>
</ul>
</li>
<% Menu.sanitized.each do |menu| %>
<% if menu.should_be_displayed? %>
<% case menu.uid %>
<% when "home" %>
<%= menu_to menu.title, root_path, class: 'menu_item' %>
<% when "calendar" %>
<%= menu_to menu.title, calendar_path(year: Time.now.year, month: Time.now.month), class: 'menu_item' %>
<% when "newsletters" %>
<li class="menu_item">
<span class="menu_title"><%= menu.title %></span>
<ul>
<% Newsletter.for_nav.each do |newsletter| %>
<%= menu_to newsletter.title, newsletter %>
<% end %>
<%= menu_to "Archives", newsletters_path %>
</ul>
</li>
<% when "activity_categories" %>
<li class="menu_item">
<span class="menu_title"><%= menu.title %></span>
<ul>
<% ActivityCategory.all.each do |cat| %>
<%= menu_to cat.title, activity_category_path(cat) %>
<% end %>
</ul>
</li>
<% when "member_groups" %>
<% unless settings.member_groups.empty? %>
<li class="menu_item">
<span class="menu_title"><%= menu.title %></span>
<ul>
<% settings.member_groups.each do |group| %>
<%= menu_to group.title, member_group_path(group) %>
<% end %>
</ul>
</li>
<% end %>
<% when "member_zone" %>
<li class="menu_item">
<span class="menu_title"><%= menu.title %></span>
<ul>
<% if logged_in? %>
<%= menu_to "Ma fiche", current_member %>
<%= menu_to "Se déconnecter", logout_path %>
<% else %>
<%= menu_to "Se connecter", login_path %>
<% end -%>
</ul>
</li>
<% else %>
<% if menu.should_be_displayed? %>
<li class="menu_item">
<span class="menu_title"><%= menu.title.upcase %></span>
<span class="menu_title"><%= menu.title %></span>
<ul>
<% menu.public_pages.each do |page| %>
<%= menu_to page.title, page %>
<% end %>
</ul>
</li>
<% end %>
<% end %>
<li class="menu_item">
<span class="menu_title">ACTIVITÉS</span>
<ul>
<% ActivityCategory.all.each do |cat| %>
<%= menu_to cat.title, activity_category_path(cat) %>
<% end %>
</ul>
</li>
<% unless settings.member_groups.empty? %>
<li class="menu_item">
<span class="menu_title">OÙ PRATIQUER</span>
<ul>
<% settings.member_groups.each do |group| %>
<%= menu_to group.title, member_group_path(group) %>
<% end %>
</ul>
</li>
<% end %>
<% end %>
<li class="menu_item">
<span class="menu_title">ZONE MEMBRE</span>
<ul>
<% if logged_in? %>
<%= menu_to "Ma fiche", current_member %>
<%= menu_to "Se déconnecter", logout_path %>
<% else %>
<%= menu_to "Se connecter", login_path %>
<% end -%>
</ul>
</li>
</ul>
</nav>
......@@ -23,11 +23,11 @@
<% pages = menu.pages %>
<h2>
<%= link_to_function menu.title, "toggle_fields('#menu-#{menu.id}')", class: 'expendable' %>
(<%= pages.length %>)
<%= "(#{pages.length})" if menu.destroyable? %>
</h2>
<div id="menu-<%= menu.id %>" style="display:none;">
<p class="AdminCard-headingActions no_print">
<%= custom_delete_link menu, :short, class: %w(tight) unless menu.uid.present? %>
<%= custom_delete_link menu, :short, class: %w(tight) if menu.destroyable? %>
<%= custom_edit_link edit_menu_path(menu), :short, class: %w(tight) %>
<%= custom_move_up_link move_up_menu_path(menu), :short, class: %w(tight) unless menu.first? %>
<%= custom_move_down_link move_down_menu_path(menu), :short, class: %w(tight) unless menu.last? %>
......
......@@ -29,3 +29,18 @@
# Mayor.create(:name => 'Daley', :city => cities.first)
Website.create()
# Fixed menus
fixed_menus = [
{ title: "Accueil", uid: "home"},
{ title: "Calendrier", uid: "calendar"},
{ title: "Lettres d'information", uid: "newsletters"},
{ title: "Activités", uid: "activity_categories"},
{ title: "Où pratiquer", uid: "member_groups"},
{ title: "Zone membre", uid: "member_zone"}
]
fixed_menus.each do |fixed_menu|
unless Menu.find_by_uid(fixed_menu[:uid])
Menu.create!(title: fixed_menu[:title], uid: fixed_menu[:uid])
end
end
......@@ -25,6 +25,10 @@ require "spec_helper"
feature "Authentication" do
before do
create :menu, title: "ZONE MEMBRE", uid: "member_zone"
end
let(:new_pass) { 'secret' }
def change_password
......@@ -110,4 +114,4 @@ feature "Authentication" do
page.should_not have_content "Vous devez aller sur votre profil pour modifier votre mot de passe!"
end
end
end
\ No newline at end of file
end
......@@ -30,11 +30,14 @@ feature "Use calendar" do
before do
@et = create :event_type
@event = create :event, begin_at: "02/07/2013 09:00", end_at: "02/07/2013 12:00", event_type: @et
end
scenario "I can see an event with dates on the calendar" do
visit calendar_path(year: 2013, month: 7)
create :menu, title: "Calendrier", uid: "calendar"
visit root_path
within "nav#main-nav" do
click_link "Calendrier"
end
within "section#content" do
page.should have_content @event.title
end
......
......@@ -479,6 +479,7 @@ feature "Manage members" do
before { login_as_member }
scenario "I can edit my information" do
create :menu, title: "Zone membre", uid: "member_zone"
new_name = "Nouvelle dénomination"
visit root_path
within "nav#main-nav" do
......
......@@ -367,6 +367,10 @@ feature "Manage newsletters" do
end
context "as a guest" do
before do
create :menu, title: "LETTRES D'INFORMATION", uid: "newsletters"
end
context "regarding a published newsletter" do
scenario "I can see it" do
newsletter = create :newsletter, published: true
......
......@@ -225,7 +225,7 @@ feature "Manage Pages" do
my_page = create :page, displayed: true, menu: create(:menu)
visit root_path
within "nav#main-nav" do
page.should have_selector("span.menu_title", text: my_page.menu.title.upcase)
page.should have_selector("span.menu_title", text: my_page.menu.title)
click_link my_page.title
end
......
......@@ -231,6 +231,7 @@ feature "Manage Settings" do
end
scenario "I can attach member groups" do
create :menu, title: "Où pratiquer", uid: "member_groups"
group1 = create :member_group
group2 = create :member_group
visit edit_settings_path
......@@ -243,7 +244,7 @@ feature "Manage Settings" do
page.should have_content "Les paramètres ont bien été mis à jour"
visit root_path
within "nav#main-nav" do
page.should have_selector("span.menu_title", text: "OÙ PRATIQUER")
page.should have_selector("span.menu_title", text: "Où pratiquer")
page.should_not have_content group1.title
page.should have_content group2.title
end
......
......@@ -77,5 +77,11 @@ describe Menu do
Menu.sanitized.should_not include(@footer)
end
end
specify "#destroyable? returns if a menu is destroyable or not" do
menu = create :menu
menu.destroyable?.should be_true
menu.update_attribute(:uid, "my_uid")
menu.destroyable?.should be_false
end
end
end
......@@ -52,10 +52,7 @@ module FeatureMacros
end
def logout
visit root_path
within "nav#main-nav" do
click_link "Se déconnecter"
end
visit logout_path
end
def click_edit_link
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment