diff --git a/app/views/shared/_admin_login_items.html.erb b/app/views/shared/_admin_login_items.html.erb index 2636f3a73..304c04fb0 100644 --- a/app/views/shared/_admin_login_items.html.erb +++ b/app/views/shared/_admin_login_items.html.erb @@ -10,4 +10,10 @@ <%= link_to t("layouts.header.moderation"), moderation_root_path %> <% end %> + + <% if current_user.valuator? || current_user.administrator? %> +
  • + <%= link_to t("layouts.header.valuation"), valuation_root_path %> +
  • + <% end %> <% end %> diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index e003e2842..c5e88d8dd 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -24,6 +24,7 @@ data: - config/locales/%{locale}.yml - config/locales/admin.%{locale}.yml - config/locales/moderation.%{locale}.yml + - config/locales/valuation.%{locale}.yml - config/locales/management.%{locale}.yml - config/locales/verification.%{locale}.yml - config/locales/mailers.%{locale}.yml @@ -122,6 +123,7 @@ ignore_unused: - 'moderation.proposals.index.order*' - 'moderation.debates.index.filter*' - 'moderation.debates.index.order*' + - 'valuation.spending_proposals.index.filter*' - 'users.show.filters.*' - 'debates.index.select_order' - 'debates.index.orders.*' diff --git a/spec/features/admin_spec.rb b/spec/features/admin_spec.rb index 644c20f9d..87c60355b 100644 --- a/spec/features/admin_spec.rb +++ b/spec/features/admin_spec.rb @@ -6,10 +6,6 @@ feature 'Admin' do create(:administrator, user: user) user end - let(:moderator) do - create(:moderator, user: user) - user - end scenario 'Access as regular user is not authorized' do login_as(user) @@ -21,7 +17,18 @@ feature 'Admin' do end scenario 'Access as a moderator is not authorized' do - login_as(moderator) + create(:moderator, user: user) + login_as(user) + visit admin_root_path + + expect(current_path).not_to eq(admin_root_path) + expect(current_path).to eq(proposals_path) + expect(page).to have_content "You do not have permission to access this page" + end + + scenario 'Access as a valuator is not authorized' do + create(:valuator, user: user) + login_as(user) visit admin_root_path expect(current_path).not_to eq(admin_root_path) @@ -42,15 +49,8 @@ feature 'Admin' do visit root_path expect(page).to have_link('Administration') - expect(page).to_not have_link('Moderator') - end - - scenario "Moderation access links" do - login_as(moderator) - visit root_path - expect(page).to have_link('Moderation') - expect(page).to_not have_link('Administration') + expect(page).to have_link('Valuation') end scenario 'Admin dashboard' do @@ -62,17 +62,7 @@ feature 'Admin' do 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 - login_as(moderator) - 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') + expect(page).to_not have_css('#valuation_menu') end context 'Tags' do diff --git a/spec/features/moderation_spec.rb b/spec/features/moderation_spec.rb index c13a23461..12eb07358 100644 --- a/spec/features/moderation_spec.rb +++ b/spec/features/moderation_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Admin' do +feature 'Moderation' do let(:user) { create(:user) } scenario 'Access as regular user is not authorized' do @@ -15,6 +15,20 @@ feature 'Admin' do expect(page).to have_content "You do not have permission to access this page" end + scenario 'Access as valuator is not authorized' do + create(:valuator, user: user) + + login_as(user) + visit root_path + + expect(page).to_not have_link("Moderation") + visit moderation_root_path + + expect(current_path).not_to eq(moderation_root_path) + expect(current_path).to eq(proposals_path) + expect(page).to have_content "You do not have permission to access this page" + end + scenario 'Access as a moderator is authorized' do create(:moderator, user: user) @@ -41,4 +55,27 @@ feature 'Admin' do expect(page).to_not have_content "You do not have permission to access this page" 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') + expect(page).to_not have_link('Valuation') + 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') + expect(page).to_not have_css('#valuation_menu') + end + end diff --git a/spec/features/valuation_spec.rb b/spec/features/valuation_spec.rb new file mode 100644 index 000000000..571a4323f --- /dev/null +++ b/spec/features/valuation_spec.rb @@ -0,0 +1,78 @@ +require 'rails_helper' + +feature 'Valuation' do + let(:user) { create(:user) } + + scenario 'Access as regular user is not authorized' do + login_as(user) + visit root_path + + expect(page).to_not have_link("Valuation") + visit valuation_root_path + + expect(current_path).not_to eq(valuation_root_path) + expect(current_path).to eq(proposals_path) + expect(page).to have_content "You do not have permission to access this page" + end + + scenario 'Access as moderator is not authorized' do + create(:moderator, user: user) + login_as(user) + visit root_path + + expect(page).to_not have_link("Valuation") + visit valuation_root_path + + expect(current_path).not_to eq(valuation_root_path) + expect(current_path).to eq(proposals_path) + expect(page).to have_content "You do not have permission to access this page" + end + + scenario 'Access as a valuator is authorized' do + create(:valuator, user: user) + login_as(user) + visit root_path + + expect(page).to have_link("Valuation") + click_on "Valuation" + + expect(current_path).to eq(valuation_root_path) + expect(page).to_not have_content "You do not have permission to access this page" + end + + scenario 'Access as an administrator is authorized' do + create(:administrator, user: user) + login_as(user) + visit root_path + + expect(page).to have_link("Valuation") + click_on "Valuation" + + expect(current_path).to eq(valuation_root_path) + expect(page).to_not have_content "You do not have permission to access this page" + end + + scenario "Valuation access links" do + create(:valuator, user: user) + login_as(user) + visit root_path + + expect(page).to have_link('Valuation') + expect(page).to_not have_link('Administration') + expect(page).to_not have_link('Moderation') + end + + scenario 'Valuation dashboard' do + create(:valuator, user: user) + login_as(user) + visit root_path + + click_link 'Valuation' + + expect(current_path).to eq(valuation_root_path) + expect(page).to have_css('#valuation_menu') + expect(page).to_not have_css('#admin_menu') + expect(page).to_not have_css('#moderation_menu') + end + +end