Merge pull request #3269 from consul/homepage-feeds
[Backport] Change layout on homepage if feed debates and proposals are enabled
This commit is contained in:
@@ -12,8 +12,20 @@ module FeedsHelper
|
|||||||
feed.kind == "processes"
|
feed.kind == "processes"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def feed_debates_enabled?
|
||||||
|
Setting["feature.homepage.widgets.feeds.debates"].present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def feed_proposals_enabled?
|
||||||
|
Setting["feature.homepage.widgets.feeds.proposals"].present?
|
||||||
|
end
|
||||||
|
|
||||||
def feed_processes_enabled?
|
def feed_processes_enabled?
|
||||||
Setting['feature.homepage.widgets.feeds.processes'].present?
|
Setting["feature.homepage.widgets.feeds.processes"].present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def feed_debates_and_proposals_enabled?
|
||||||
|
feed_debates_enabled? && feed_proposals_enabled?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
<% @feeds.each do |feed| %>
|
<% @feeds.each do |feed| %>
|
||||||
|
|
||||||
<% if feed_proposals?(feed) %>
|
<% if feed_proposals?(feed) %>
|
||||||
<div class="small-12 medium-8 column margin-top">
|
<div id="feed_proposals" class="small-12 column margin-top
|
||||||
|
<%= 'medium-8' if feed_debates_and_proposals_enabled? %>">
|
||||||
<div class="feed-content" data-equalizer-watch>
|
<div class="feed-content" data-equalizer-watch>
|
||||||
<h3 class="title"><%= t("welcome.feed.most_active.#{feed.kind}") %></h3>
|
<h3 class="title"><%= t("welcome.feed.most_active.#{feed.kind}") %></h3>
|
||||||
|
|
||||||
@@ -16,7 +17,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="feed-description small-12 column <%= 'large-9' if feature?(:allow_images) && item.image.present? %>">
|
<div class="feed-description small-12 column
|
||||||
|
<%= 'large-9' if feature?(:allow_images) && item.image.present? %>">
|
||||||
<strong><%= link_to item.title, url_for(item) %></strong><br>
|
<strong><%= link_to item.title, url_for(item) %></strong><br>
|
||||||
<p><%= item.summary %></p>
|
<p><%= item.summary %></p>
|
||||||
</div>
|
</div>
|
||||||
@@ -29,7 +31,8 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if feed_debates?(feed) %>
|
<% if feed_debates?(feed) %>
|
||||||
<div class="small-12 medium-4 column margin-top">
|
<div id="feed_debates" class="small-12 column margin-top
|
||||||
|
<%= 'medium-4' if feed_debates_and_proposals_enabled? %>">
|
||||||
<div class="feed-content" data-equalizer-watch>
|
<div class="feed-content" data-equalizer-watch>
|
||||||
<h3 class="title"><%= t("welcome.feed.most_active.#{feed.kind}") %></h3>
|
<h3 class="title"><%= t("welcome.feed.most_active.#{feed.kind}") %></h3>
|
||||||
|
|
||||||
|
|||||||
@@ -39,14 +39,18 @@ feature 'Homepage' do
|
|||||||
visit admin_homepage_path
|
visit admin_homepage_path
|
||||||
|
|
||||||
within("#widget_feed_#{proposals_feed.id}") do
|
within("#widget_feed_#{proposals_feed.id}") do
|
||||||
select '1', from: 'widget_feed_limit'
|
select "1", from: "widget_feed_limit"
|
||||||
accept_confirm { click_button "Enable" }
|
accept_confirm { click_button "Enable" }
|
||||||
end
|
end
|
||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
expect(page).to have_content "Most active proposals"
|
within("#feed_proposals") do
|
||||||
expect(page).to have_css(".proposal", count: 1)
|
expect(page).to have_content "Most active proposals"
|
||||||
|
expect(page).to have_css(".proposal", count: 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).not_to have_css("#feed_proposals.medium-8")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Debates", :js do
|
scenario "Debates", :js do
|
||||||
@@ -54,14 +58,50 @@ feature 'Homepage' do
|
|||||||
|
|
||||||
visit admin_homepage_path
|
visit admin_homepage_path
|
||||||
within("#widget_feed_#{debates_feed.id}") do
|
within("#widget_feed_#{debates_feed.id}") do
|
||||||
select '2', from: 'widget_feed_limit'
|
select "2", from: "widget_feed_limit"
|
||||||
accept_confirm { click_button "Enable" }
|
accept_confirm { click_button "Enable" }
|
||||||
end
|
end
|
||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
expect(page).to have_content "Most active debates"
|
within("#feed_debates") do
|
||||||
expect(page).to have_css(".debate", count: 2)
|
expect(page).to have_content "Most active debates"
|
||||||
|
expect(page).to have_css(".debate", count: 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).not_to have_css("#feed_debates.medium-4")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Proposals and debates", :js do
|
||||||
|
3.times { create(:proposal) }
|
||||||
|
3.times { create(:debate) }
|
||||||
|
|
||||||
|
visit admin_homepage_path
|
||||||
|
|
||||||
|
within("#widget_feed_#{proposals_feed.id}") do
|
||||||
|
select "3", from: "widget_feed_limit"
|
||||||
|
accept_confirm { click_button "Enable" }
|
||||||
|
end
|
||||||
|
|
||||||
|
within("#widget_feed_#{debates_feed.id}") do
|
||||||
|
select "3", from: "widget_feed_limit"
|
||||||
|
accept_confirm { click_button "Enable" }
|
||||||
|
end
|
||||||
|
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
within("#feed_proposals") do
|
||||||
|
expect(page).to have_content "Most active proposals"
|
||||||
|
expect(page).to have_css(".proposal", count: 3)
|
||||||
|
end
|
||||||
|
|
||||||
|
within("#feed_debates") do
|
||||||
|
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
|
end
|
||||||
|
|
||||||
scenario "Processes", :js do
|
scenario "Processes", :js do
|
||||||
|
|||||||
Reference in New Issue
Block a user