From 61ddbcfe0408822d250283c0993a9aefd26a45da Mon Sep 17 00:00:00 2001 From: shlok007 Date: Sat, 26 Aug 2017 15:11:40 +0530 Subject: [PATCH] link to organization#new from user menu --- .../layouts/_admin_sidebar_index.html.haml | 9 ++++--- app/views/layouts/_user_menu.html.haml | 8 +++++-- spec/features/user_menu_spec.rb | 24 +++++++++++++++++++ 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 spec/features/user_menu_spec.rb diff --git a/app/views/layouts/_admin_sidebar_index.html.haml b/app/views/layouts/_admin_sidebar_index.html.haml index 01356f42..da05ca50 100644 --- a/app/views/layouts/_admin_sidebar_index.html.haml +++ b/app/views/layouts/_admin_sidebar_index.html.haml @@ -23,6 +23,10 @@ New Conference - if can? :index, User %hr + %li + = link_to(admin_organizations_path) do + %span.fa.fa-group + Organizations %li = link_to(admin_users_path) do %span.fa.fa-user @@ -32,8 +36,3 @@ = link_to(admin_revision_history_path) do %span.fa.fa-history Revision History - - if ENV['ORGANIZATIONS_ENABLED'] == 'true' - %li - = link_to(admin_organizations_path) do - %span.fa.fa-group - Organizations diff --git a/app/views/layouts/_user_menu.html.haml b/app/views/layouts/_user_menu.html.haml index 38a96b08..aad34bd8 100644 --- a/app/views/layouts/_user_menu.html.haml +++ b/app/views/layouts/_user_menu.html.haml @@ -28,8 +28,12 @@ = link_to(admin_conferences_path()) do %span.fa.fa-home Administration - - if can? :new, Conference.new - =link_to(new_admin_conference_path) do + - if (can? :new, Organization.new) && !Organization.any? + = link_to(new_admin_organization_path) do + %span.fa.fa-plus + New Organization + - if (can? :new, Conference.new) && Organization.any? + = link_to(new_admin_conference_path) do %span.fa.fa-plus New Conference -if @conference and @conference.id and can? :show, @conference diff --git a/spec/features/user_menu_spec.rb b/spec/features/user_menu_spec.rb new file mode 100644 index 00000000..7d0231f4 --- /dev/null +++ b/spec/features/user_menu_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +feature '_user_menu' do + let(:admin) { create(:admin) } + subject { page } + before { sign_in admin } + + scenario 'when no organization is present', feature: true, js: true do + visit root_path + click_link admin.name + + is_expected.to have_text('New Organization') + is_expected.to_not have_text('New Conference') + end + + scenario 'when organization is present', feature: true, js: true do + create(:organization) + visit root_path + click_link admin.name + + is_expected.to_not have_text('New Organization') + is_expected.to have_text('New Conference') + end +end