Render participation feeds per SDG
This commit is contained in:
@@ -2790,7 +2790,8 @@ table {
|
|||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
.home-page,
|
.home-page,
|
||||||
.custom-page {
|
.custom-page,
|
||||||
|
.sdg-goal-show {
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.sdg-goal-show {
|
.sdg-goal-show {
|
||||||
@include grid-row;
|
@include grid-row;
|
||||||
|
|
||||||
> * {
|
> :not(.feeds-participation) {
|
||||||
@include grid-column-gutter;
|
@include grid-column-gutter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,6 @@
|
|||||||
<h1><%= goal.title %></h1>
|
<h1><%= goal.title %></h1>
|
||||||
</header>
|
</header>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
<%= render Widgets::Feeds::ParticipationComponent.new(feeds) %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,4 +5,8 @@ class SDG::Goals::ShowComponent < ApplicationComponent
|
|||||||
def initialize(goal)
|
def initialize(goal)
|
||||||
@goal = goal
|
@goal = goal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def feeds
|
||||||
|
SDG::Widget::Feed.for_goal(goal)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
17
app/models/sdg/widget/feed.rb
Normal file
17
app/models/sdg/widget/feed.rb
Normal file
@@ -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
|
||||||
@@ -33,10 +33,27 @@ describe "SDG Goals", :js do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "Show" do
|
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)
|
visit sdg_goal_path(15)
|
||||||
|
|
||||||
within(".sdg-goal header") { expect(page).to have_content "Life on Land" }
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user