Fixed issue shown resources in the dashboard

This commit is contained in:
Juan Salvador Pérez García
2018-06-21 12:19:40 +02:00
parent 8239b789fa
commit e1ac6bfa01
4 changed files with 13 additions and 5 deletions

View File

@@ -4,7 +4,7 @@
class ProposalsDashboardController < ApplicationController class ProposalsDashboardController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
helper_method :proposal, :proposed_actions, :proposal_dashboard_action helper_method :proposal, :proposed_actions, :resources, :proposal_dashboard_action
respond_to :html respond_to :html
layout 'proposals_dashboard' layout 'proposals_dashboard'
@@ -76,4 +76,8 @@ class ProposalsDashboardController < ApplicationController
def proposed_actions def proposed_actions
@proposed_actions ||= ProposalDashboardAction.proposed_actions.active_for(proposal) @proposed_actions ||= ProposalDashboardAction.proposed_actions.active_for(proposal)
end end
def resources
@resources ||= ProposalDashboardAction.resources.active_for(proposal)
end
end end

View File

@@ -44,8 +44,8 @@ class ProposalDashboardAction < ActiveRecord::Base
scope :active, -> { where(active: true) } scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) } scope :inactive, -> { where(active: false) }
scope :resources, -> { where(action_type: 'resource') } scope :resources, -> { where(action_type: 1) }
scope :proposed_actions, -> { where(action_type: 'proposed_action') } scope :proposed_actions, -> { where(action_type: 0) }
scope :active_for, ->(proposal) do scope :active_for, ->(proposal) do
published_at = proposal.published_at&.to_date || Date.today published_at = proposal.published_at&.to_date || Date.today

View File

@@ -75,13 +75,13 @@
</div> </div>
</div> </div>
<% if proposed_actions.resources.any? %> <% if resources.any? %>
<div class="row"> <div class="row">
<div class="small-2 columns"></div> <div class="small-2 columns"></div>
<div class="small-10 columns"><%= t '.resources' %></div> <div class="small-10 columns"><%= t '.resources' %></div>
</div> </div>
<% proposed_actions.resources.each do |resource| %> <% resources.each do |resource| %>
<div class="row"> <div class="row">
<div class="small-2 columns"></div> <div class="small-2 columns"></div>
<div class="small-10 columns"> <div class="small-10 columns">

View File

@@ -43,6 +43,10 @@ Capybara.register_driver :headless_chrome do |app|
) )
end end
Capybara::Screenshot.register_driver(:headless_chrome) do |driver, path|
driver.browser.save_screenshot(path)
end
Capybara.asset_host = 'http://localhost:3000' Capybara.asset_host = 'http://localhost:3000'
Capybara::Screenshot.prune_strategy = :keep_last_run Capybara::Screenshot.prune_strategy = :keep_last_run
Capybara.javascript_driver = :headless_chrome Capybara.javascript_driver = :headless_chrome