Merge branch 'master' into update-dependencies
This commit is contained in:
@@ -129,16 +129,16 @@ module CommentableActions
|
|||||||
when '4'
|
when '4'
|
||||||
1.year.ago
|
1.year.ago
|
||||||
else
|
else
|
||||||
Date.parse(params[:advanced_search][:date_min]) rescue nil
|
Date.parse(params[:advanced_search][:date_min]) rescue 100.years.ago
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_finish_date
|
def search_finish_date
|
||||||
params[:advanced_search][:date_max].try(:to_date) || Date.today
|
(params[:advanced_search][:date_max].to_date rescue Date.today) || Date.today
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_date_range
|
def search_date_range
|
||||||
search_start_date.beginning_of_day..search_finish_date.end_of_day
|
[100.years.ago, search_start_date].max.beginning_of_day..[search_finish_date, Date.today].min.end_of_day
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_search_order
|
def set_search_order
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class Budget
|
|||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
validates :heading_id, presence: true
|
validates :heading_id, presence: true
|
||||||
validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required?
|
validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required?
|
||||||
|
validates_presence_of :price, if: :price_required?
|
||||||
|
|
||||||
validates :title, length: { in: 4..Budget::Investment.title_max_length }
|
validates :title, length: { in: 4..Budget::Investment.title_max_length }
|
||||||
validates :description, length: { maximum: Budget::Investment.description_max_length }
|
validates :description, length: { maximum: Budget::Investment.description_max_length }
|
||||||
@@ -136,6 +137,10 @@ class Budget
|
|||||||
unfeasible? && valuation_finished?
|
unfeasible? && valuation_finished?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def price_required?
|
||||||
|
feasible? && valuation_finished?
|
||||||
|
end
|
||||||
|
|
||||||
def unfeasible_email_pending?
|
def unfeasible_email_pending?
|
||||||
unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
|
unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
<div class="social-share-full">
|
<div class="social-share-full">
|
||||||
<%= social_share_button_tag("#{investment.title} #{setting['twitter_hashtag']}") %>
|
<%= social_share_button_tag("#{investment.title} #{setting['twitter_hashtag']}") %>
|
||||||
<% if browser.device.mobile? %>
|
<% if browser.device.mobile? %>
|
||||||
<a href="whatsapp://send?text=<%= investment.title %> <%= budget_investment_url(budget_id: investment.budget_id, id: investment.id) %>" data-action="share/whatsapp/share">
|
<a href="whatsapp://send?text=<%= investment.title.gsub(/\s/, ' ') %> <%= budget_investment_url(budget_id: investment.budget_id, id: investment.id) %>" data-action="share/whatsapp/share">
|
||||||
<span class="icon-whatsapp whatsapp"></span>
|
<span class="icon-whatsapp whatsapp"></span>
|
||||||
<span class="sr-only"><%= t("social.whatsapp") %></span>
|
<span class="sr-only"><%= t("social.whatsapp") %></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
<div class="social-share-full">
|
<div class="social-share-full">
|
||||||
<%= social_share_button_tag("#{@debate.title} #{setting['twitter_hashtag']}") %>
|
<%= social_share_button_tag("#{@debate.title} #{setting['twitter_hashtag']}") %>
|
||||||
<% if browser.device.mobile? %>
|
<% if browser.device.mobile? %>
|
||||||
<a href="whatsapp://send?text=<%= @debate.title %> <%= debate_url(@debate) %>" data-action="share/whatsapp/share">
|
<a href="whatsapp://send?text=<%= @debate.title.gsub(/\s/, ' ') %> <%= debate_url(@debate) %>" data-action="share/whatsapp/share">
|
||||||
<span class="icon-whatsapp whatsapp"></span>
|
<span class="icon-whatsapp whatsapp"></span>
|
||||||
<span class="sr-only"><%= t("social.whatsapp") %></span>
|
<span class="sr-only"><%= t("social.whatsapp") %></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -126,7 +126,7 @@
|
|||||||
<div class="social-share-full">
|
<div class="social-share-full">
|
||||||
<%= social_share_button_tag("#{@proposal.title} #{setting['twitter_hashtag']}") %>
|
<%= social_share_button_tag("#{@proposal.title} #{setting['twitter_hashtag']}") %>
|
||||||
<% if browser.device.mobile? %>
|
<% if browser.device.mobile? %>
|
||||||
<a href="whatsapp://send?text=<%= @proposal.title %> <%= proposal_url(@proposal) %>" data-action="share/whatsapp/share">
|
<a href="whatsapp://send?text=<%= @proposal.title.gsub(/\s/, ' ') %> <%= proposal_url(@proposal) %>" data-action="share/whatsapp/share">
|
||||||
<span class="icon-whatsapp whatsapp"></span>
|
<span class="icon-whatsapp whatsapp"></span>
|
||||||
<span class="sr-only"><%= t("social.whatsapp") %></span>
|
<span class="sr-only"><%= t("social.whatsapp") %></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<div class="social-share-full">
|
<div class="social-share-full">
|
||||||
<%= social_share_button_tag("#{@spending_proposal.title} #{setting['twitter_hashtag']}") %>
|
<%= social_share_button_tag("#{@spending_proposal.title} #{setting['twitter_hashtag']}") %>
|
||||||
<% if browser.device.mobile? %>
|
<% if browser.device.mobile? %>
|
||||||
<a href="whatsapp://send?text=<%= @spending_proposal.title %> <%= spending_proposal_url(@spending_proposal) %>" data-action="share/whatsapp/share">
|
<a href="whatsapp://send?text=<%= @spending_proposal.title.gsub(/\s/, ' ') %> <%= spending_proposal_url(@spending_proposal) %>" data-action="share/whatsapp/share">
|
||||||
<span class="icon-whatsapp whatsapp"></span>
|
<span class="icon-whatsapp whatsapp"></span>
|
||||||
<span class="sr-only"><%= t("social.whatsapp") %></span>
|
<span class="sr-only"><%= t("social.whatsapp") %></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -640,6 +640,28 @@ feature 'Debates' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Search by custom invalid date range", :js do
|
||||||
|
debate1 = create(:debate, created_at: 2.years.ago)
|
||||||
|
debate2 = create(:debate, created_at: 3.days.ago)
|
||||||
|
debate3 = create(:debate, created_at: 9.days.ago)
|
||||||
|
|
||||||
|
visit debates_path
|
||||||
|
|
||||||
|
click_link "Advanced search"
|
||||||
|
select "Customized", from: "js-advanced-search-date-min"
|
||||||
|
fill_in "advanced_search_date_min", with: "9"
|
||||||
|
fill_in "advanced_search_date_max", with: "444444444"
|
||||||
|
click_button "Filter"
|
||||||
|
|
||||||
|
within("#debates") do
|
||||||
|
expect(page).to have_css('.debate', count: 3)
|
||||||
|
|
||||||
|
expect(page).to have_content(debate1.title)
|
||||||
|
expect(page).to have_content(debate2.title)
|
||||||
|
expect(page).to have_content(debate3.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Search by multiple filters", :js do
|
scenario "Search by multiple filters", :js do
|
||||||
ana = create :user, official_level: 1
|
ana = create :user, official_level: 1
|
||||||
john = create :user, official_level: 1
|
john = create :user, official_level: 1
|
||||||
|
|||||||
@@ -980,6 +980,28 @@ feature 'Proposals' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Search by custom invalid date range", :js do
|
||||||
|
proposal1 = create(:proposal, created_at: 2.days.ago)
|
||||||
|
proposal2 = create(:proposal, created_at: 3.days.ago)
|
||||||
|
proposal3 = create(:proposal, created_at: 9.days.ago)
|
||||||
|
|
||||||
|
visit proposals_path
|
||||||
|
|
||||||
|
click_link "Advanced search"
|
||||||
|
select "Customized", from: "js-advanced-search-date-min"
|
||||||
|
fill_in "advanced_search_date_min", with: 4000.years.ago
|
||||||
|
fill_in "advanced_search_date_max", with: "wrong date"
|
||||||
|
click_button "Filter"
|
||||||
|
|
||||||
|
expect(page).to have_content("There are 3 citizen proposals")
|
||||||
|
|
||||||
|
within("#proposals") do
|
||||||
|
expect(page).to have_content(proposal1.title)
|
||||||
|
expect(page).to have_content(proposal2.title)
|
||||||
|
expect(page).to have_content(proposal3.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Search by multiple filters", :js do
|
scenario "Search by multiple filters", :js do
|
||||||
ana = create :user, official_level: 1
|
ana = create :user, official_level: 1
|
||||||
john = create :user, official_level: 1
|
john = create :user, official_level: 1
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ describe Budget::Investment do
|
|||||||
expect(investment.group_id).to eq group_2.id
|
expect(investment.group_id).to eq group_2.id
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#unfeasibility_explanation" do
|
describe "#unfeasibility_explanation blank" do
|
||||||
it "should be valid if valuation not finished" do
|
it "should be valid if valuation not finished" do
|
||||||
investment.unfeasibility_explanation = ""
|
investment.unfeasibility_explanation = ""
|
||||||
investment.valuation_finished = false
|
investment.valuation_finished = false
|
||||||
@@ -76,6 +76,29 @@ describe Budget::Investment do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#price blank" do
|
||||||
|
it "should be valid if valuation not finished" do
|
||||||
|
investment.price = ""
|
||||||
|
investment.valuation_finished = false
|
||||||
|
expect(investment).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be valid if valuation finished and unfeasible" do
|
||||||
|
investment.price = ""
|
||||||
|
investment.unfeasibility_explanation = "reason"
|
||||||
|
investment.feasibility = "unfeasible"
|
||||||
|
investment.valuation_finished = true
|
||||||
|
expect(investment).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not be valid if valuation finished and feasible" do
|
||||||
|
investment.price = ""
|
||||||
|
investment.feasibility = "feasible"
|
||||||
|
investment.valuation_finished = true
|
||||||
|
expect(investment).to_not be_valid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#code" do
|
describe "#code" do
|
||||||
let(:investment) { create(:budget_investment) }
|
let(:investment) { create(:budget_investment) }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user