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
Render participation feeds per SDG
  • Loading branch information
javierm committed Dec 27, 2020
commit 2fcfa7ebd718c66b85230c55aacb5bb5006d7590
3 changes: 2 additions & 1 deletion app/assets/stylesheets/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,8 @@ table {
// ------------

.home-page,
.custom-page {
.custom-page,
.sdg-goal-show {

a {

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/sdg/goals/show.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.sdg-goal-show {
@include grid-row;

> * {
> :not(.feeds-participation) {
@include grid-column-gutter;
}

Expand Down
2 changes: 2 additions & 0 deletions app/components/sdg/goals/show_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
<h1><%= goal.title %></h1>
</header>
</article>

<%= render Widgets::Feeds::ParticipationComponent.new(feeds) %>
</div>
4 changes: 4 additions & 0 deletions app/components/sdg/goals/show_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ class SDG::Goals::ShowComponent < ApplicationComponent
def initialize(goal)
@goal = goal
end

def feeds
SDG::Widget::Feed.for_goal(goal)
end
end
17 changes: 17 additions & 0 deletions app/models/sdg/widget/feed.rb
Original file line number Diff line number Diff line change
@@ -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
19 changes: 18 additions & 1 deletion spec/system/sdg/goals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,27 @@
end

describe "Show" do
scenario "shows the SDG" do
scenario "shows the SDG and its related content" 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]])

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
end
end
end