Add empty SDG index
This commit is contained in:
0
app/components/sdg/goals/index_component.html.erb
Normal file
0
app/components/sdg/goals/index_component.html.erb
Normal file
7
app/components/sdg/goals/index_component.rb
Normal file
7
app/components/sdg/goals/index_component.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class SDG::Goals::IndexComponent < ApplicationComponent
|
||||||
|
attr_reader :goals
|
||||||
|
|
||||||
|
def initialize(goals)
|
||||||
|
@goals = goals
|
||||||
|
end
|
||||||
|
end
|
||||||
9
app/controllers/sdg/goals_controller.rb
Normal file
9
app/controllers/sdg/goals_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class SDG::GoalsController < ApplicationController
|
||||||
|
include FeatureFlags
|
||||||
|
feature_flag :sdg
|
||||||
|
load_and_authorize_resource
|
||||||
|
|
||||||
|
def index
|
||||||
|
@goals = @goals.order(:code)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -27,6 +27,8 @@ module Abilities
|
|||||||
can [:read], Legislation::Question
|
can [:read], Legislation::Question
|
||||||
can [:read, :map, :share], Legislation::Proposal
|
can [:read, :map, :share], Legislation::Proposal
|
||||||
can [:search, :comments, :read, :create, :new_comment], Legislation::Annotation
|
can [:search, :comments, :read, :create, :new_comment], Legislation::Annotation
|
||||||
|
|
||||||
|
can :read, ::SDG::Goal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ class Abilities::SDG::Manager
|
|||||||
def initialize(user)
|
def initialize(user)
|
||||||
merge Abilities::Common.new(user)
|
merge Abilities::Common.new(user)
|
||||||
|
|
||||||
can :read, ::SDG::Goal
|
|
||||||
can :read, ::SDG::Target
|
can :read, ::SDG::Target
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
1
app/views/sdg/goals/index.html.erb
Normal file
1
app/views/sdg/goals/index.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<%= render SDG::Goals::IndexComponent.new(@goals) %>
|
||||||
@@ -42,12 +42,20 @@
|
|||||||
accesskey: "5" %>
|
accesskey: "5" %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if feature?(:sdg) %>
|
||||||
|
<li>
|
||||||
|
<%= layout_menu_link_to t("layouts.header.sdg"),
|
||||||
|
sdg_goals_path,
|
||||||
|
controller_path.split("/").first == "sdg",
|
||||||
|
accesskey: "6" %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
<% if feature?(:help_page) %>
|
<% if feature?(:help_page) %>
|
||||||
<li>
|
<li>
|
||||||
<%= layout_menu_link_to t("layouts.header.help"),
|
<%= layout_menu_link_to t("layouts.header.help"),
|
||||||
help_path,
|
help_path,
|
||||||
current_page?(help_path),
|
current_page?(help_path),
|
||||||
accesskey: "6" %>
|
accesskey: "7" %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ en:
|
|||||||
other: You have %{count} new notifications
|
other: You have %{count} new notifications
|
||||||
notifications: Notifications
|
notifications: Notifications
|
||||||
no_notifications: "You don't have new notifications"
|
no_notifications: "You don't have new notifications"
|
||||||
|
sdg: "SDG"
|
||||||
notifications:
|
notifications:
|
||||||
index:
|
index:
|
||||||
empty_notifications: You don't have new notifications.
|
empty_notifications: You don't have new notifications.
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ es:
|
|||||||
other: Tienes %{count} notificaciones nuevas
|
other: Tienes %{count} notificaciones nuevas
|
||||||
notifications: Notificaciones
|
notifications: Notificaciones
|
||||||
no_notifications: "No tienes notificaciones nuevas"
|
no_notifications: "No tienes notificaciones nuevas"
|
||||||
|
sdg: "ODS"
|
||||||
notifications:
|
notifications:
|
||||||
index:
|
index:
|
||||||
empty_notifications: No tienes notificaciones nuevas.
|
empty_notifications: No tienes notificaciones nuevas.
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ Rails.application.routes.draw do
|
|||||||
draw :poll
|
draw :poll
|
||||||
draw :proposal
|
draw :proposal
|
||||||
draw :related_content
|
draw :related_content
|
||||||
|
draw :sdg
|
||||||
draw :sdg_management
|
draw :sdg_management
|
||||||
draw :tag
|
draw :tag
|
||||||
draw :user
|
draw :user
|
||||||
|
|||||||
3
config/routes/sdg.rb
Normal file
3
config/routes/sdg.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
namespace :sdg do
|
||||||
|
resources :goals, only: :index
|
||||||
|
end
|
||||||
13
spec/controllers/sdg/goals_spec.rb
Normal file
13
spec/controllers/sdg/goals_spec.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe SDG::GoalsController do
|
||||||
|
context "featured disabled" do
|
||||||
|
before do
|
||||||
|
Setting["feature.sdg"] = false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "raises feature disabled" do
|
||||||
|
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -107,7 +107,6 @@ describe Abilities::Administrator do
|
|||||||
it { should be_able_to(:create, LocalCensusRecords::Import) }
|
it { should be_able_to(:create, LocalCensusRecords::Import) }
|
||||||
it { should be_able_to(:show, LocalCensusRecords::Import) }
|
it { should be_able_to(:show, LocalCensusRecords::Import) }
|
||||||
|
|
||||||
it { should be_able_to(:read, SDG::Goal) }
|
|
||||||
it { should be_able_to(:read, SDG::Target) }
|
it { should be_able_to(:read, SDG::Target) }
|
||||||
|
|
||||||
it { should be_able_to(:read, SDG::Manager) }
|
it { should be_able_to(:read, SDG::Manager) }
|
||||||
|
|||||||
@@ -305,7 +305,6 @@ describe Abilities::Common do
|
|||||||
it { should be_able_to(:disable_recommendations, Proposal) }
|
it { should be_able_to(:disable_recommendations, Proposal) }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Goal) }
|
|
||||||
it { should_not be_able_to(:read, SDG::Target) }
|
it { should_not be_able_to(:read, SDG::Target) }
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Manager) }
|
it { should_not be_able_to(:read, SDG::Manager) }
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ describe Abilities::Everyone do
|
|||||||
it { should_not be_able_to(:summary, create(:legislation_process, :open)) }
|
it { should_not be_able_to(:summary, create(:legislation_process, :open)) }
|
||||||
it { should_not be_able_to(:summary, create(:legislation_process, :past, :not_published)) }
|
it { should_not be_able_to(:summary, create(:legislation_process, :past, :not_published)) }
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Goal) }
|
it { should be_able_to(:read, SDG::Goal) }
|
||||||
it { should_not be_able_to(:read, SDG::Target) }
|
it { should_not be_able_to(:read, SDG::Target) }
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Manager) }
|
it { should_not be_able_to(:read, SDG::Manager) }
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ describe Abilities::Moderator do
|
|||||||
it { should_not be_able_to(:comment_as_administrator, legislation_question) }
|
it { should_not be_able_to(:comment_as_administrator, legislation_question) }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Goal) }
|
|
||||||
it { should_not be_able_to(:read, SDG::Target) }
|
it { should_not be_able_to(:read, SDG::Target) }
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Manager) }
|
it { should_not be_able_to(:read, SDG::Manager) }
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ describe "Abilities::Organization" do
|
|||||||
it { should be_able_to(:create, Comment) }
|
it { should be_able_to(:create, Comment) }
|
||||||
it { should_not be_able_to(:vote, Comment) }
|
it { should_not be_able_to(:vote, Comment) }
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Goal) }
|
|
||||||
it { should_not be_able_to(:read, SDG::Target) }
|
it { should_not be_able_to(:read, SDG::Target) }
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Manager) }
|
it { should_not be_able_to(:read, SDG::Manager) }
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ describe "Abilities::SDG::Manager" do
|
|||||||
let(:user) { sdg_manager.user }
|
let(:user) { sdg_manager.user }
|
||||||
let(:sdg_manager) { create(:sdg_manager) }
|
let(:sdg_manager) { create(:sdg_manager) }
|
||||||
|
|
||||||
it { should be_able_to(:read, SDG::Goal) }
|
|
||||||
it { should be_able_to(:read, SDG::Target) }
|
it { should be_able_to(:read, SDG::Target) }
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Manager) }
|
it { should_not be_able_to(:read, SDG::Manager) }
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ describe Abilities::Valuator do
|
|||||||
it { should_not be_able_to(:comment_valuation, assigned_investment) }
|
it { should_not be_able_to(:comment_valuation, assigned_investment) }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Goal) }
|
|
||||||
it { should_not be_able_to(:read, SDG::Target) }
|
it { should_not be_able_to(:read, SDG::Target) }
|
||||||
|
|
||||||
it { should_not be_able_to(:read, SDG::Manager) }
|
it { should_not be_able_to(:read, SDG::Manager) }
|
||||||
|
|||||||
24
spec/system/sdg/goals_spec.rb
Normal file
24
spec/system/sdg/goals_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
describe "SDG Goals", :js do
|
||||||
|
before do
|
||||||
|
Setting["feature.sdg"] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "SDG navigation link" do
|
||||||
|
scenario "is not present when the feature is disabled" do
|
||||||
|
Setting["feature.sdg"] = false
|
||||||
|
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
within("#navigation_bar") { expect(page).not_to have_link "SDG" }
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "routes to the goals index" do
|
||||||
|
visit root_path
|
||||||
|
within("#navigation_bar") { click_link "SDG" }
|
||||||
|
|
||||||
|
expect(page).to have_current_path sdg_goals_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user