diff --git a/app/assets/stylesheets/_consul_settings.scss b/app/assets/stylesheets/_consul_settings.scss
index 54cf561d174..1864a76addd 100644
--- a/app/assets/stylesheets/_consul_settings.scss
+++ b/app/assets/stylesheets/_consul_settings.scss
@@ -123,3 +123,23 @@ $pagination-radius: $global-radius;
$show-header-for-stacked: true;
$tooltip-background-color: $brand;
+
+$sdg-colors: (
+ 1: #e92140,
+ 2: #e0a33a,
+ 3: #4ca149,
+ 4: #c72032,
+ 5: #ef3e2e,
+ 6: #27c1ec,
+ 7: #fac312,
+ 8: #a61c45,
+ 9: #f26a30,
+ 10: #df1767,
+ 11: #f59d29,
+ 12: #bc8b2a,
+ 13: #437e47,
+ 14: #2296d7,
+ 15: #5db84a,
+ 16: #16699d,
+ 17: #15476d
+);
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index daa8ffc81f0..38c4185fcf2 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -28,4 +28,6 @@
@import "leaflet";
@import "sticky_overrides";
@import "admin/*";
+@import "sdg/**/*";
@import "sdg_management/*";
+@import "widgets/**/*";
diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss
index fae431c76a8..27488cc0f6b 100644
--- a/app/assets/stylesheets/layout.scss
+++ b/app/assets/stylesheets/layout.scss
@@ -2790,7 +2790,8 @@ table {
// ------------
.home-page,
-.custom-page {
+.custom-page,
+.sdg-goal-show {
a {
@@ -2855,6 +2856,13 @@ table {
}
}
+ h2 {
+ &.title {
+ @include header-font-size(h3);
+ }
+ }
+
+ h2,
h3 {
&.title {
@@ -2889,10 +2897,6 @@ table {
.feeds-list {
- .proposal {
- clear: both;
- }
-
a {
&.see-all {
@@ -2906,22 +2910,6 @@ table {
}
}
-.feed-image {
- display: inline-block;
- height: rem-calc(120);
- overflow: hidden;
- width: 100%;
-
- @include breakpoint(medium) {
- height: rem-calc(96);
- }
-
- img {
- max-width: none;
- width: 100%;
- }
-}
-
.feed-description {
p {
diff --git a/app/assets/stylesheets/mixins.scss b/app/assets/stylesheets/mixins.scss
index 875a1b9130e..99afec57a6e 100644
--- a/app/assets/stylesheets/mixins.scss
+++ b/app/assets/stylesheets/mixins.scss
@@ -209,3 +209,11 @@
text-decoration: none;
}
}
+
+@mixin header-font-size($heading-tag) {
+ @each $size, $headers in $header-styles {
+ @include breakpoint($size) {
+ font-size: rem-calc(map-get(map-get($headers, $heading-tag), font-size));
+ }
+ }
+}
diff --git a/app/assets/stylesheets/sdg/goals/show.scss b/app/assets/stylesheets/sdg/goals/show.scss
new file mode 100644
index 00000000000..13b3842154a
--- /dev/null
+++ b/app/assets/stylesheets/sdg/goals/show.scss
@@ -0,0 +1,40 @@
+.sdg-goal-show {
+ @include grid-row;
+
+ > :not(.feeds-participation) {
+ @include grid-column-gutter;
+ }
+
+ .sdg-goal {
+
+ > header {
+ color: #fff;
+ margin-top: $line-height / 2;
+ padding-left: rem-calc(24);
+ text-shadow: 0 0 1px $black;
+ }
+
+ @each $code, $color in $sdg-colors {
+ &.sdg-goal-#{$code} {
+ > header {
+ background-color: $color;
+ }
+ }
+ }
+ }
+
+ .feed-processes {
+
+ .feed-content {
+ @include breakpoint(medium) {
+ @include grid-row-nest;
+ display: flex;
+
+ > * {
+ @include grid-column-gutter;
+ width: 50%;
+ }
+ }
+ }
+ }
+}
diff --git a/app/assets/stylesheets/widgets/feeds/participation.scss b/app/assets/stylesheets/widgets/feeds/participation.scss
new file mode 100644
index 00000000000..350eb9a6fd4
--- /dev/null
+++ b/app/assets/stylesheets/widgets/feeds/participation.scss
@@ -0,0 +1,30 @@
+.feeds-participation {
+
+ @include breakpoint(medium) {
+ display: flex;
+
+ .feed-proposals:not(:only-child) {
+ width: 2 * 100% / 3;
+ }
+
+ .feed-debates:not(:only-child) {
+ width: 1 * 100% / 3;
+ }
+
+ .feed-proposals,
+ .feed-debates {
+ display: flex;
+ flex-direction: column;
+
+ .feed-content {
+ flex: 1;
+ }
+ }
+ }
+
+ .feed-debates,
+ .feed-proposals {
+ @include grid-col;
+ margin-top: $line-height;
+ }
+}
diff --git a/app/assets/stylesheets/widgets/feeds/proposal.scss b/app/assets/stylesheets/widgets/feeds/proposal.scss
new file mode 100644
index 00000000000..f771c63f5f8
--- /dev/null
+++ b/app/assets/stylesheets/widgets/feeds/proposal.scss
@@ -0,0 +1,19 @@
+.feed-proposals .proposal {
+ clear: both;
+
+ .feed-image {
+ display: inline-block;
+ height: rem-calc(120);
+ overflow: hidden;
+ width: 100%;
+
+ @include breakpoint(medium) {
+ height: rem-calc(96);
+ }
+
+ img {
+ max-width: none;
+ width: 100%;
+ }
+ }
+}
diff --git a/app/components/sdg/goals/index_component.html.erb b/app/components/sdg/goals/index_component.html.erb
index e69de29bb2d..d475bf90bc2 100644
--- a/app/components/sdg/goals/index_component.html.erb
+++ b/app/components/sdg/goals/index_component.html.erb
@@ -0,0 +1 @@
+<%= link_list(*goals.map { |goal| [goal.code_and_title, sdg_goal_path(goal.code)] }) %>
diff --git a/app/components/sdg/goals/index_component.rb b/app/components/sdg/goals/index_component.rb
index 3d89921cad2..e8907916685 100644
--- a/app/components/sdg/goals/index_component.rb
+++ b/app/components/sdg/goals/index_component.rb
@@ -1,5 +1,6 @@
class SDG::Goals::IndexComponent < ApplicationComponent
attr_reader :goals
+ delegate :link_list, to: :helpers
def initialize(goals)
@goals = goals
diff --git a/app/components/sdg/goals/show_component.html.erb b/app/components/sdg/goals/show_component.html.erb
new file mode 100644
index 00000000000..862bd0763f4
--- /dev/null
+++ b/app/components/sdg/goals/show_component.html.erb
@@ -0,0 +1,19 @@
+<% provide(:title) { goal.title } %>
+
+
+ <%= back_link_to sdg_goals_path %>
+
+
+
+
+
+ <%= render Widgets::Feeds::ParticipationComponent.new(feeds) %>
+
+ <% if processes_feed %>
+
+ <%= render Widgets::Feeds::FeedComponent.new(processes_feed) %>
+
+ <% end %>
+
diff --git a/app/components/sdg/goals/show_component.rb b/app/components/sdg/goals/show_component.rb
new file mode 100644
index 00000000000..531967906b5
--- /dev/null
+++ b/app/components/sdg/goals/show_component.rb
@@ -0,0 +1,18 @@
+class SDG::Goals::ShowComponent < ApplicationComponent
+ attr_reader :goal
+ delegate :back_link_to, to: :helpers
+
+ def initialize(goal)
+ @goal = goal
+ end
+
+ def feeds
+ SDG::Widget::Feed.for_goal(goal)
+ end
+
+ private
+
+ def processes_feed
+ feeds.find { |feed| feed.kind == "processes" }
+ end
+end
diff --git a/app/components/widgets/feeds/debate_component.html.erb b/app/components/widgets/feeds/debate_component.html.erb
new file mode 100644
index 00000000000..ba93fa7c138
--- /dev/null
+++ b/app/components/widgets/feeds/debate_component.html.erb
@@ -0,0 +1,3 @@
+
+ <%= link_to debate.title, url_for(debate) %>
+
diff --git a/app/components/widgets/feeds/debate_component.rb b/app/components/widgets/feeds/debate_component.rb
new file mode 100644
index 00000000000..28d726811fc
--- /dev/null
+++ b/app/components/widgets/feeds/debate_component.rb
@@ -0,0 +1,7 @@
+class Widgets::Feeds::DebateComponent < ApplicationComponent
+ attr_reader :debate
+
+ def initialize(debate)
+ @debate = debate
+ end
+end
diff --git a/app/components/widgets/feeds/feed_component.html.erb b/app/components/widgets/feeds/feed_component.html.erb
new file mode 100644
index 00000000000..5f071623ad4
--- /dev/null
+++ b/app/components/widgets/feeds/feed_component.html.erb
@@ -0,0 +1,13 @@
+
+
+ <%= t("welcome.feed.most_active.#{kind}") %>
+
+
+
+ <% feed.items.each do |item| %>
+ <%= render item_component_class.new(item) %>
+ <% end %>
+
+
+ <%= link_to t("welcome.feed.see_all.#{kind}"), see_all_path, class: "see-all" %>
+
diff --git a/app/components/widgets/feeds/feed_component.rb b/app/components/widgets/feeds/feed_component.rb
new file mode 100644
index 00000000000..cf476382ac4
--- /dev/null
+++ b/app/components/widgets/feeds/feed_component.rb
@@ -0,0 +1,33 @@
+class Widgets::Feeds::FeedComponent < ApplicationComponent
+ attr_reader :feed
+ delegate :kind, to: :feed
+
+ def initialize(feed)
+ @feed = feed
+ end
+
+ def see_all_path
+ polymorphic_path(feed.items.model, filters)
+ end
+
+ private
+
+ def item_component_class
+ case kind
+ when "proposals"
+ Widgets::Feeds::ProposalComponent
+ when "debates"
+ Widgets::Feeds::DebateComponent
+ when "processes"
+ Widgets::Feeds::ProcessComponent
+ end
+ end
+
+ def filters
+ if feed.respond_to?(:goal) && kind != "processes"
+ { advanced_search: { goal: feed.goal.code }}
+ else
+ {}
+ end
+ end
+end
diff --git a/app/components/widgets/feeds/participation_component.html.erb b/app/components/widgets/feeds/participation_component.html.erb
new file mode 100644
index 00000000000..f19bd0e4fdc
--- /dev/null
+++ b/app/components/widgets/feeds/participation_component.html.erb
@@ -0,0 +1,7 @@
+
+ <% feeds.each do |feed| %>
+ <% if feed_proposals?(feed) || feed_debates?(feed) %>
+ <%= render Widgets::Feeds::FeedComponent.new(feed) %>
+ <% end %>
+ <% end %>
+
diff --git a/app/components/widgets/feeds/participation_component.rb b/app/components/widgets/feeds/participation_component.rb
new file mode 100644
index 00000000000..f90b731c3d1
--- /dev/null
+++ b/app/components/widgets/feeds/participation_component.rb
@@ -0,0 +1,17 @@
+class Widgets::Feeds::ParticipationComponent < ApplicationComponent
+ attr_reader :feeds
+
+ def initialize(feeds)
+ @feeds = feeds
+ end
+
+ private
+
+ def feed_debates?(feed)
+ feed.kind == "debates"
+ end
+
+ def feed_proposals?(feed)
+ feed.kind == "proposals"
+ end
+end
diff --git a/app/components/widgets/feeds/process_component.html.erb b/app/components/widgets/feeds/process_component.html.erb
new file mode 100644
index 00000000000..ff7619cacfd
--- /dev/null
+++ b/app/components/widgets/feeds/process_component.html.erb
@@ -0,0 +1,13 @@
+
+ <%= link_to url_for(process) do %>
+
+
<%= process.summary %>
+
<%= t("welcome.feed.see_process") %>
+ <% end %>
+
diff --git a/app/components/widgets/feeds/process_component.rb b/app/components/widgets/feeds/process_component.rb
new file mode 100644
index 00000000000..5d9f79f0f3c
--- /dev/null
+++ b/app/components/widgets/feeds/process_component.rb
@@ -0,0 +1,7 @@
+class Widgets::Feeds::ProcessComponent < ApplicationComponent
+ attr_reader :process
+
+ def initialize(process)
+ @process = process
+ end
+end
diff --git a/app/components/widgets/feeds/proposal_component.html.erb b/app/components/widgets/feeds/proposal_component.html.erb
new file mode 100644
index 00000000000..b94696d510a
--- /dev/null
+++ b/app/components/widgets/feeds/proposal_component.html.erb
@@ -0,0 +1,16 @@
+
+
">
+
<%= link_to proposal.title, url_for(proposal) %>
+
<%= proposal.summary %>
+
+
+ <% if proposal.image.present? %>
+
+
+ <%= image_tag proposal.image_url(:thumb),
+ alt: proposal.image.title.unicode_normalize %>
+
+
+ <% end %>
+
diff --git a/app/components/widgets/feeds/proposal_component.rb b/app/components/widgets/feeds/proposal_component.rb
new file mode 100644
index 00000000000..243bb0649ab
--- /dev/null
+++ b/app/components/widgets/feeds/proposal_component.rb
@@ -0,0 +1,7 @@
+class Widgets::Feeds::ProposalComponent < ApplicationComponent
+ attr_reader :proposal
+
+ def initialize(proposal)
+ @proposal = proposal
+ end
+end
diff --git a/app/controllers/sdg/goals_controller.rb b/app/controllers/sdg/goals_controller.rb
index ea5498c2bae..595add701bd 100644
--- a/app/controllers/sdg/goals_controller.rb
+++ b/app/controllers/sdg/goals_controller.rb
@@ -1,9 +1,12 @@
class SDG::GoalsController < ApplicationController
include FeatureFlags
feature_flag :sdg
- load_and_authorize_resource
+ load_and_authorize_resource find_by: :code, id_param: :code
def index
@goals = @goals.order(:code)
end
+
+ def show
+ end
end
diff --git a/app/helpers/feeds_helper.rb b/app/helpers/feeds_helper.rb
index b5882e22fd3..d9bcb9aea34 100644
--- a/app/helpers/feeds_helper.rb
+++ b/app/helpers/feeds_helper.rb
@@ -1,29 +1,9 @@
module FeedsHelper
- def feed_debates?(feed)
- feed.kind == "debates"
- end
-
- def feed_proposals?(feed)
- feed.kind == "proposals"
- end
-
def feed_processes?(feed)
feed.kind == "processes"
end
- def feed_debates_enabled?
- Setting["homepage.widgets.feeds.debates"].present?
- end
-
- def feed_proposals_enabled?
- Setting["homepage.widgets.feeds.proposals"].present?
- end
-
def feed_processes_enabled?
Setting["homepage.widgets.feeds.processes"].present?
end
-
- def feed_debates_and_proposals_enabled?
- feed_debates_enabled? && feed_proposals_enabled?
- end
end
diff --git a/app/models/concerns/filterable.rb b/app/models/concerns/filterable.rb
index 31d64ae892e..0c752058079 100644
--- a/app/models/concerns/filterable.rb
+++ b/app/models/concerns/filterable.rb
@@ -20,7 +20,7 @@ def filter_by(params)
def allowed_filter?(filter, value)
return if value.blank?
- ["official_level", "date_range"].include?(filter)
+ ["official_level", "date_range", "goal"].include?(filter)
end
end
end
diff --git a/app/models/sdg/widget/feed.rb b/app/models/sdg/widget/feed.rb
new file mode 100644
index 00000000000..445af5e698e
--- /dev/null
+++ b/app/models/sdg/widget/feed.rb
@@ -0,0 +1,17 @@
+class SDG::Widget::Feed
+ attr_reader :feed, :goal
+ delegate :kind, to: :feed
+
+ def initialize(feed, goal)
+ @feed = feed
+ @goal = goal
+ end
+
+ def items
+ feed.items.by_goal(goal.code)
+ end
+
+ def self.for_goal(goal)
+ ::Widget::Feed.active.map { |feed| new(feed, goal) }
+ end
+end
diff --git a/app/views/sdg/goals/show.html.erb b/app/views/sdg/goals/show.html.erb
new file mode 100644
index 00000000000..2eb01851179
--- /dev/null
+++ b/app/views/sdg/goals/show.html.erb
@@ -0,0 +1 @@
+<%= render SDG::Goals::ShowComponent.new(@goal) %>
diff --git a/app/views/welcome/_feeds.html.erb b/app/views/welcome/_feeds.html.erb
index 37f21df1873..e200d2c42d8 100644
--- a/app/views/welcome/_feeds.html.erb
+++ b/app/views/welcome/_feeds.html.erb
@@ -1,51 +1 @@
-
- <% @feeds.each do |feed| %>
-
- <% if feed_proposals?(feed) %>
-
">
-
-
<%= t("welcome.feed.most_active.#{feed.kind}") %>
-
- <% feed.items.each do |item| %>
-
row">
-
">
-
<%= link_to item.title, url_for(item) %>
-
<%= item.summary %>
-
- <% if item.image.present? %>
-
-
- <%= image_tag item.image_url(:thumb),
- alt: item.image.title.unicode_normalize %>
-
-
- <% end %>
-
- <% end %>
-
-
- <%= link_to t("welcome.feed.see_all_proposals"), proposals_path, class: "see-all" %>
-
- <% end %>
-
- <% if feed_debates?(feed) %>
-
">
-
-
<%= t("welcome.feed.most_active.#{feed.kind}") %>
-
- <% feed.items.each do |item| %>
-
">
- <%= link_to item.title, url_for(item) %>
-
- <% end %>
-
-
- <%= link_to t("welcome.feed.see_all_debates"), debates_path, class: "see-all" %>
-
- <% end %>
-
- <% end %>
-
+<%= render Widgets::Feeds::ParticipationComponent.new(@feeds) %>
diff --git a/app/views/welcome/_processes.html.erb b/app/views/welcome/_processes.html.erb
index 556c6e06618..4b0f191d3e7 100644
--- a/app/views/welcome/_processes.html.erb
+++ b/app/views/welcome/_processes.html.erb
@@ -2,27 +2,7 @@
<% @feeds.each do |feed| %>
<% if feed_processes?(feed) %>
-
-
-
<%= t("welcome.feed.most_active.#{feed.kind}") %>
-
- <% feed.items.each do |item| %>
- <%= link_to url_for(item) do %>
-
-
<%= item.summary %>
-
<%= t("welcome.feed.see_process") %>
- <% end %>
- <% end %>
-
- <%= link_to t("welcome.feed.see_all_processes"), legislation_processes_path, class: "float-right see-all" %>
-
-
+ <%= render Widgets::Feeds::FeedComponent.new(feed) %>
<% end %>
<% end %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index fafbcafbbc4..94e3a04b2ba 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -19,7 +19,7 @@
<% if @cards.any? %>
">
-
<%= t("welcome.cards.title") %>
+ <%= t("welcome.cards.title") %>
<%= render "shared/cards" %>
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index a1c7a886ce5..05fc01c7115 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -875,9 +875,10 @@ en:
debates: "Most active debates"
proposals: "Most active proposals"
processes: "Open processes"
- see_all_debates: See all debates
- see_all_proposals: See all proposals
- see_all_processes: See all processes
+ see_all:
+ debates: See all debates
+ proposals: See all proposals
+ processes: See all processes
process_label: Process
see_process: See process
cards:
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index b9da8ab10f6..d5f998ecc7a 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -875,9 +875,10 @@ es:
debates: "Debates más activos"
proposals: "Propuestas más activas"
processes: "Procesos abiertos"
- see_all_debates: Ver todos los debates
- see_all_proposals: Ver todas las propuestas
- see_all_processes: Ver todos los procesos
+ see_all:
+ debates: Ver todos los debates
+ proposals: Ver todas las propuestas
+ processes: Ver todos los procesos
process_label: Proceso
see_process: Ver proceso
cards:
diff --git a/config/routes/sdg.rb b/config/routes/sdg.rb
index 9c065b9a6fc..52525c68574 100644
--- a/config/routes/sdg.rb
+++ b/config/routes/sdg.rb
@@ -1,3 +1,3 @@
namespace :sdg do
- resources :goals, only: :index
+ resources :goals, param: :code, only: [:index, :show]
end
diff --git a/db/sdg.rb b/db/sdg.rb
index 9dde1885ba8..f81741e77ee 100644
--- a/db/sdg.rb
+++ b/db/sdg.rb
@@ -1,4 +1,4 @@
-(1..17).each do |code|
+(1..17).to_a.shuffle.each do |code|
SDG::Goal.where(code: code).first_or_create!
end
diff --git a/spec/components/widgets/feeds/feed_component_spec.rb b/spec/components/widgets/feeds/feed_component_spec.rb
new file mode 100644
index 00000000000..09974de0b31
--- /dev/null
+++ b/spec/components/widgets/feeds/feed_component_spec.rb
@@ -0,0 +1,65 @@
+require "rails_helper"
+
+describe Widgets::Feeds::FeedComponent, type: :component do
+ describe "#see_all_path" do
+ context "debates" do
+ let(:feed) { Widget::Feed.new(kind: "debates") }
+
+ it "points to the debates path for homepage debates feeds" do
+ component = Widgets::Feeds::FeedComponent.new(feed)
+
+ render_inline component
+
+ expect(component.see_all_path).to eq "/debates"
+ end
+
+ it "points to the debates filtered by goal for goal feeds" do
+ component = Widgets::Feeds::FeedComponent.new(SDG::Widget::Feed.new(feed, SDG::Goal[6]))
+
+ render_inline component
+
+ expect(component.see_all_path).to eq "/debates?advanced_search#{CGI.escape("[goal]")}=6"
+ end
+ end
+
+ context "proposals" do
+ let(:feed) { Widget::Feed.new(kind: "proposals") }
+
+ it "points to the proposals path for homepage proposals feeds" do
+ component = Widgets::Feeds::FeedComponent.new(feed)
+
+ render_inline component
+
+ expect(component.see_all_path).to eq "/proposals"
+ end
+
+ it "points to the proposals filtered by goal for goal feeds" do
+ component = Widgets::Feeds::FeedComponent.new(SDG::Widget::Feed.new(feed, SDG::Goal[6]))
+
+ render_inline component
+
+ expect(component.see_all_path).to eq "/proposals?advanced_search#{CGI.escape("[goal]")}=6"
+ end
+ end
+
+ context "processes" do
+ let(:feed) { Widget::Feed.new(kind: "processes") }
+
+ it "points to the legislation processes path for homepage processes feeds" do
+ component = Widgets::Feeds::FeedComponent.new(feed)
+
+ render_inline component
+
+ expect(component.see_all_path).to eq "/legislation/processes"
+ end
+
+ it "points to the legislation processes path for goal processes feeds" do
+ component = Widgets::Feeds::FeedComponent.new(SDG::Widget::Feed.new(feed, SDG::Goal[6]))
+
+ render_inline component
+
+ expect(component.see_all_path).to eq "/legislation/processes"
+ end
+ end
+ end
+end
diff --git a/spec/routing/sdg_routes_spec.rb b/spec/routing/sdg_routes_spec.rb
new file mode 100644
index 00000000000..d3dbcb398c0
--- /dev/null
+++ b/spec/routing/sdg_routes_spec.rb
@@ -0,0 +1,19 @@
+require "rails_helper"
+
+describe "SDG routes" do
+ it "maps goals to their code" do
+ expect(get("/sdg/goals/1")).to route_to(
+ controller: "sdg/goals",
+ action: "show",
+ code: "1"
+ )
+ end
+
+ it "requires using the code instead of the ID" do
+ expect(get(sdg_goal_path(SDG::Goal[2].code))).to route_to(
+ controller: "sdg/goals",
+ action: "show",
+ code: "2"
+ )
+ end
+end
diff --git a/spec/system/admin/homepage/homepage_spec.rb b/spec/system/admin/homepage/homepage_spec.rb
index 0e3eff79a2a..b6349376ac9 100644
--- a/spec/system/admin/homepage/homepage_spec.rb
+++ b/spec/system/admin/homepage/homepage_spec.rb
@@ -92,9 +92,6 @@
expect(page).to have_content "Most active debates"
expect(page).to have_css(".debate", count: 3)
end
-
- expect(page).to have_css("#feed_proposals.medium-8")
- expect(page).to have_css("#feed_debates.medium-4")
end
scenario "Processes", :js do
@@ -109,7 +106,7 @@
visit root_path
expect(page).to have_content "Open processes"
- expect(page).to have_css(".legislation_process", count: 3)
+ expect(page).to have_css(".legislation-process", count: 3)
end
xscenario "Deactivate"
diff --git a/spec/system/sdg/goals_spec.rb b/spec/system/sdg/goals_spec.rb
index 313765c5c5f..3231a6f80d1 100644
--- a/spec/system/sdg/goals_spec.rb
+++ b/spec/system/sdg/goals_spec.rb
@@ -21,4 +21,68 @@
expect(page).to have_current_path sdg_goals_path
end
end
+
+ describe "Index" do
+ scenario "has links to SDGs" do
+ visit sdg_goals_path
+
+ click_link "7. Affordable and Clean Energy"
+
+ expect(page).to have_current_path sdg_goal_path(7)
+ end
+ end
+
+ describe "Show" do
+ before do
+ goal = SDG::Goal[15]
+
+ create(:debate, title: "Solar panels", sdg_goals: [SDG::Goal[7]])
+ create(:debate, title: "Hunting ground", sdg_goals: [goal])
+ create(:proposal, title: "Animal farm", sdg_goals: [goal])
+ create(:proposal, title: "Sea farm", sdg_goals: [SDG::Goal[14]])
+ create(:legislation_process, title: "Bullfighting regulations", sdg_goals: [goal])
+ create(:legislation_process, title: "Tax regulations", sdg_goals: [SDG::Goal[10]])
+ end
+
+ scenario "shows the SDG and its related content" do
+ visit sdg_goal_path(15)
+
+ within(".sdg-goal header") { expect(page).to have_content "Life on Land" }
+
+ within ".feed-proposals" do
+ expect(page).to have_content "Animal farm"
+ expect(page).not_to have_content "Sea farm"
+ end
+
+ within ".feed-debates" do
+ expect(page).to have_content "Hunting ground"
+ expect(page).not_to have_content "Solar panels"
+ end
+
+ within ".feed-processes" do
+ expect(page).to have_content "BULLFIGHTING REGULATIONS"
+ expect(page).not_to have_content "TAX REGULATIONS"
+ end
+ end
+
+ scenario "has links to debates and proposals filtered by goal" do
+ visit sdg_goal_path(15)
+
+ click_link "See all debates"
+
+ within "#debates" do
+ expect(page).to have_content "Hunting ground"
+ expect(page).not_to have_content "Solar panels"
+ end
+
+ go_back
+
+ click_link "See all proposals"
+
+ within "#proposals" do
+ expect(page).to have_content "Animal farm"
+ expect(page).not_to have_content "Sea farm"
+ end
+ end
+ end
end