adds valuation links and access specs
This commit is contained in:
committed by
Juanjo Bazán
parent
ac9eaec9d9
commit
da855207d3
@@ -10,4 +10,10 @@
|
||||
<%= link_to t("layouts.header.moderation"), moderation_root_path %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if current_user.valuator? || current_user.administrator? %>
|
||||
<li>
|
||||
<%= link_to t("layouts.header.valuation"), valuation_root_path %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -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.*'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
78
spec/features/valuation_spec.rb
Normal file
78
spec/features/valuation_spec.rb
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user