Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SDG view with related content #4292

Merged
merged 15 commits into from
Dec 28, 2020
Merged
Prev Previous commit
Next Next commit
Add processes to goal view
Note the link to see all processes does not filter by goal because the
legislation section does not have any search filters.
  • Loading branch information
javierm committed Dec 27, 2020
commit cc9ab70fbb0ef9422f38375b8840ac77bf7e2554
15 changes: 15 additions & 0 deletions app/assets/stylesheets/sdg/goals/show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,19 @@
}
}
}

.feed-processes {

.feed-content {
@include breakpoint(medium) {
@include grid-row-nest;
display: flex;

> * {
@include grid-column-gutter;
width: 50%;
}
}
}
}
}
6 changes: 6 additions & 0 deletions app/components/sdg/goals/show_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@
</article>

<%= render Widgets::Feeds::ParticipationComponent.new(feeds) %>

<% if processes_feed %>
<div class="feeds-list">
<%= render Widgets::Feeds::FeedComponent.new(processes_feed) %>
</div>
<% end %>
</div>
6 changes: 6 additions & 0 deletions app/components/sdg/goals/show_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ def initialize(goal)
def feeds
SDG::Widget::Feed.for_goal(goal)
end

private

def processes_feed
feeds.find { |feed| feed.kind == "processes" }
end
end
2 changes: 1 addition & 1 deletion app/components/widgets/feeds/feed_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def item_component_class
end

def filters
if feed.respond_to?(:goal)
if feed.respond_to?(:goal) && kind != "processes"
{ advanced_search: { goal: feed.goal.code }}
else
{}
Expand Down
8 changes: 8 additions & 0 deletions spec/components/widgets/feeds/feed_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@

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
7 changes: 7 additions & 0 deletions spec/system/sdg/goals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
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
Expand All @@ -56,6 +58,11 @@
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
Expand Down