Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys are aligned and values aren't) instead of the `table` style (both keys and values are aligned) because, even if we used both in the application, we used the `key` style a lot more. Furthermore, the `table` style looks strange in places where there are both very long and very short keys and sometimes we weren't even consistent with the `table` style, aligning some keys without aligning other keys. Ideally we could align hashes to "either key or table", so developers can decide whether keeping the symmetry of the code is worth it in a case-per-case basis, but Rubocop doesn't allow this option.
This commit is contained in:
13
.rubocop.yml
13
.rubocop.yml
@@ -64,6 +64,13 @@ Layout/FirstArrayElementIndentation:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
EnforcedStyle: consistent
|
EnforcedStyle: consistent
|
||||||
|
|
||||||
|
Layout/FirstHashElementIndentation:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: consistent
|
||||||
|
|
||||||
|
Layout/HashAlignment:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
Layout/HeredocIndentation:
|
Layout/HeredocIndentation:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
@@ -92,6 +99,12 @@ Layout/MultilineArrayBraceLayout:
|
|||||||
Layout/MultilineBlockLayout:
|
Layout/MultilineBlockLayout:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
Layout/MultilineHashBraceLayout:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
|
Layout/MultilineHashKeyLineBreaks:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
Layout/SpaceAfterColon:
|
Layout/SpaceAfterColon:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<% if user %>
|
<% if user %>
|
||||||
<li id="notifications">
|
<li id="notifications">
|
||||||
<%= link_to notifications_path, rel: "nofollow", title: text,
|
<%= link_to notifications_path, rel: "nofollow",
|
||||||
|
title: text,
|
||||||
class: "notifications #{notifications_class}" do %>
|
class: "notifications #{notifications_class}" do %>
|
||||||
<span class="show-for-sr">
|
<span class="show-for-sr">
|
||||||
<%= t("layouts.header.notification_item.notifications") %>
|
<%= t("layouts.header.notification_item.notifications") %>
|
||||||
|
|||||||
@@ -37,8 +37,10 @@ class Admin::BudgetsWizard::BudgetsController < Admin::BudgetsWizard::BaseContro
|
|||||||
end
|
end
|
||||||
|
|
||||||
def allowed_params
|
def allowed_params
|
||||||
valid_attributes = [:currency_symbol, :voting_style, :hide_money, administrator_ids: [],
|
valid_attributes = [:currency_symbol, :voting_style, :hide_money,
|
||||||
valuator_ids: [], image_attributes: image_attributes]
|
administrator_ids: [],
|
||||||
|
valuator_ids: [],
|
||||||
|
image_attributes: image_attributes]
|
||||||
|
|
||||||
[*valid_attributes, translation_params(Budget)]
|
[*valid_attributes, translation_params(Budget)]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ class Dashboard::ActionsController < Dashboard::BaseController
|
|||||||
def execute
|
def execute
|
||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
|
|
||||||
Dashboard::ExecutedAction.create(proposal: proposal, action: dashboard_action,
|
Dashboard::ExecutedAction.create(proposal: proposal,
|
||||||
|
action: dashboard_action,
|
||||||
executed_at: Time.current)
|
executed_at: Time.current)
|
||||||
redirect_to request.referer
|
redirect_to request.referer
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -203,7 +203,8 @@ class Budget
|
|||||||
end
|
end
|
||||||
|
|
||||||
def searchable_values
|
def searchable_values
|
||||||
{ author.username => "B",
|
{
|
||||||
|
author.username => "B",
|
||||||
heading.name => "B",
|
heading.name => "B",
|
||||||
tag_list.join(" ") => "B"
|
tag_list.join(" ") => "B"
|
||||||
}.merge(searchable_globalized_values)
|
}.merge(searchable_globalized_values)
|
||||||
|
|||||||
@@ -44,17 +44,20 @@
|
|||||||
|
|
||||||
<div class="row expanded margin-top">
|
<div class="row expanded margin-top">
|
||||||
<div class="small-12 medium-4 column">
|
<div class="small-12 medium-4 column">
|
||||||
<%= f.number_field :day_offset, step: 1, min: 0,
|
<%= f.number_field :day_offset, step: 1,
|
||||||
|
min: 0,
|
||||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-4 column">
|
<div class="small-12 medium-4 column">
|
||||||
<%= f.number_field :required_supports, step: 1, min: 0,
|
<%= f.number_field :required_supports, step: 1,
|
||||||
|
min: 0,
|
||||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-4 column">
|
<div class="small-12 medium-4 column">
|
||||||
<%= f.number_field :order, step: 1, min: 0,
|
<%= f.number_field :order, step: 1,
|
||||||
|
min: 0,
|
||||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<%= render "shared/globalize_locales", resource: @draft_version %>
|
<%= render "shared/globalize_locales", resource: @draft_version %>
|
||||||
|
|
||||||
<%= translatable_form_for [:admin, @process, @draft_version], url: url,
|
<%= translatable_form_for [:admin, @process, @draft_version], url: url,
|
||||||
html: { data: { markdown_changes_message: I18n.t("admin.legislation.draft_versions.edit.markdown_changes_message") }} do |f| %>
|
html: {
|
||||||
|
data: {
|
||||||
|
markdown_changes_message: I18n.t("admin.legislation.draft_versions.edit.markdown_changes_message")
|
||||||
|
}
|
||||||
|
} do |f| %>
|
||||||
<%= render "shared/errors", resource: @draft_version %>
|
<%= render "shared/errors", resource: @draft_version %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -50,7 +53,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-6 column markdown-area">
|
<div class="small-12 medium-6 column markdown-area">
|
||||||
<%= translations_form.text_area :body, label: false, rows: 10,
|
<%= translations_form.text_area :body, label: false,
|
||||||
|
rows: 10,
|
||||||
class: "legislation-draft-version-body" %>
|
class: "legislation-draft-version-body" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-6 column">
|
<div class="small-12 medium-6 column">
|
||||||
<%= f.text_field :slug, size: 80, maxlength: 80,
|
<%= f.text_field :slug, size: 80,
|
||||||
|
maxlength: 80,
|
||||||
hint: sanitize(t("admin.site_customization.pages.new.slug_help")) %>
|
hint: sanitize(t("admin.site_customization.pages.new.slug_help")) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= form_for poll, remote: true, data: { type: :json },
|
<%= form_for poll, remote: true,
|
||||||
|
data: { type: :json },
|
||||||
url: proposal_dashboard_poll_path(proposal, poll) do |f| %>
|
url: proposal_dashboard_poll_path(proposal, poll) do |f| %>
|
||||||
<%= f.check_box :results_enabled, class: "js-submit-on-change" %>
|
<%= f.check_box :results_enabled, class: "js-submit-on-change" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
<%= f.hidden_field :reset_password_token %>
|
<%= f.hidden_field :reset_password_token %>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= f.password_field :password, autofocus: true, autocomplete: "off",
|
<%= f.password_field :password, autofocus: true,
|
||||||
|
autocomplete: "off",
|
||||||
label: t("devise_views.passwords.edit.password_label") %>
|
label: t("devise_views.passwords.edit.password_label") %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<li id="<%= dom_id(document) %>">
|
<li id="<%= dom_id(document) %>">
|
||||||
<%= link_to t("documents.buttons.download_document"),
|
<%= link_to t("documents.buttons.download_document"),
|
||||||
document.attachment, target: "_blank",
|
document.attachment,
|
||||||
rel: "nofollow", class: "button hollow medium float-right" %>
|
target: "_blank",
|
||||||
|
rel: "nofollow",
|
||||||
|
class: "button hollow medium float-right" %>
|
||||||
|
|
||||||
<strong><%= document.title %></strong>
|
<strong><%= document.title %></strong>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
<%= link_to t("management.users.create_user"),
|
<%= link_to t("management.users.create_user"),
|
||||||
new_management_user_path(user: {
|
new_management_user_path(user: {
|
||||||
document_number: @email_verification.document_number,
|
document_number: @email_verification.document_number,
|
||||||
document_type: @email_verification.document_type }),
|
document_type: @email_verification.document_type
|
||||||
|
}),
|
||||||
class: "button success" %>
|
class: "button success" %>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<%= link_to t("notifications.index.mark_all_as_read"),
|
<%= link_to t("notifications.index.mark_all_as_read"),
|
||||||
mark_all_as_read_notifications_path, method: :put,
|
mark_all_as_read_notifications_path,
|
||||||
|
method: :put,
|
||||||
class: "button hollow float-right-medium" %>
|
class: "button hollow float-right-medium" %>
|
||||||
|
|
||||||
<ul class="menu simple clear">
|
<ul class="menu simple clear">
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td id="actions" class="text-center">
|
<td id="actions" class="text-center">
|
||||||
<%= form_for @user, as: :voter, url: officing_voters_path,
|
<%= form_for @user, as: :voter,
|
||||||
method: :post, remote: true,
|
url: officing_voters_path,
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
html: { id: "new_officing_voter" } do |f| %>
|
html: { id: "new_officing_voter" } do |f| %>
|
||||||
<%= f.hidden_field :poll_id, value: poll.id %>
|
<%= f.hidden_field :poll_id, value: poll.id %>
|
||||||
<%= f.hidden_field :user_id, value: @user.id %>
|
<%= f.hidden_field :user_id, value: @user.id %>
|
||||||
|
|||||||
@@ -32,7 +32,8 @@
|
|||||||
class: "button hollow expanded" %>
|
class: "button hollow expanded" %>
|
||||||
|
|
||||||
<%= link_to t("community.show.topic.destroy"),
|
<%= link_to t("community.show.topic.destroy"),
|
||||||
community_topic_path(@community.id, @topic), method: :delete,
|
community_topic_path(@community.id, @topic),
|
||||||
|
method: :delete,
|
||||||
class: "button hollow expanded alert" %>
|
class: "button hollow expanded alert" %>
|
||||||
</aside>
|
</aside>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ devise_for :users, controllers: {
|
|||||||
sessions: "users/sessions",
|
sessions: "users/sessions",
|
||||||
confirmations: "users/confirmations",
|
confirmations: "users/confirmations",
|
||||||
omniauth_callbacks: "users/omniauth_callbacks"
|
omniauth_callbacks: "users/omniauth_callbacks"
|
||||||
}
|
}
|
||||||
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
patch "/user/confirmation", to: "users/confirmations#update", as: :update_user_confirmation
|
patch "/user/confirmation", to: "users/confirmations#update", as: :update_user_confirmation
|
||||||
|
|||||||
@@ -35,44 +35,57 @@ section "Creating Users" do
|
|||||||
manager = create_user("manager@consul.dev", "manager")
|
manager = create_user("manager@consul.dev", "manager")
|
||||||
manager.create_manager
|
manager.create_manager
|
||||||
manager.update!(residence_verified_at: Time.current,
|
manager.update!(residence_verified_at: Time.current,
|
||||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
confirmed_phone: Faker::PhoneNumber.phone_number,
|
||||||
verified_at: Time.current, document_number: unique_document_number)
|
document_type: "1",
|
||||||
|
verified_at: Time.current,
|
||||||
|
document_number: unique_document_number)
|
||||||
|
|
||||||
valuator = create_user("valuator@consul.dev", "valuator")
|
valuator = create_user("valuator@consul.dev", "valuator")
|
||||||
valuator.create_valuator
|
valuator.create_valuator
|
||||||
valuator.update!(residence_verified_at: Time.current,
|
valuator.update!(residence_verified_at: Time.current,
|
||||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
confirmed_phone: Faker::PhoneNumber.phone_number,
|
||||||
verified_at: Time.current, document_number: unique_document_number)
|
document_type: "1",
|
||||||
|
verified_at: Time.current,
|
||||||
|
document_number: unique_document_number)
|
||||||
|
|
||||||
poll_officer = create_user("poll_officer@consul.dev", "Paul O. Fisher")
|
poll_officer = create_user("poll_officer@consul.dev", "Paul O. Fisher")
|
||||||
poll_officer.create_poll_officer
|
poll_officer.create_poll_officer
|
||||||
poll_officer.update!(residence_verified_at: Time.current,
|
poll_officer.update!(residence_verified_at: Time.current,
|
||||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
confirmed_phone: Faker::PhoneNumber.phone_number,
|
||||||
verified_at: Time.current, document_number: unique_document_number)
|
document_type: "1",
|
||||||
|
verified_at: Time.current,
|
||||||
|
document_number: unique_document_number)
|
||||||
|
|
||||||
poll_officer2 = create_user("poll_officer2@consul.dev", "Pauline M. Espinosa")
|
poll_officer2 = create_user("poll_officer2@consul.dev", "Pauline M. Espinosa")
|
||||||
poll_officer2.create_poll_officer
|
poll_officer2.create_poll_officer
|
||||||
poll_officer2.update!(residence_verified_at: Time.current,
|
poll_officer2.update!(residence_verified_at: Time.current,
|
||||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
confirmed_phone: Faker::PhoneNumber.phone_number,
|
||||||
verified_at: Time.current, document_number: unique_document_number)
|
document_type: "1",
|
||||||
|
verified_at: Time.current,
|
||||||
|
document_number: unique_document_number)
|
||||||
|
|
||||||
sdg_manager = create_user("sdg_manager@consul.dev", "SDG manager")
|
sdg_manager = create_user("sdg_manager@consul.dev", "SDG manager")
|
||||||
sdg_manager.create_sdg_manager
|
sdg_manager.create_sdg_manager
|
||||||
sdg_manager.update!(residence_verified_at: Time.current,
|
sdg_manager.update!(residence_verified_at: Time.current,
|
||||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
confirmed_phone: Faker::PhoneNumber.phone_number,
|
||||||
verified_at: Time.current, document_number: unique_document_number)
|
document_type: "1",
|
||||||
|
verified_at: Time.current,
|
||||||
|
document_number: unique_document_number)
|
||||||
|
|
||||||
create_user("unverified@consul.dev", "unverified")
|
create_user("unverified@consul.dev", "unverified")
|
||||||
|
|
||||||
level_2 = create_user("leveltwo@consul.dev", "level 2")
|
level_2 = create_user("leveltwo@consul.dev", "level 2")
|
||||||
level_2.update!(residence_verified_at: Time.current,
|
level_2.update!(residence_verified_at: Time.current,
|
||||||
confirmed_phone: Faker::PhoneNumber.phone_number,
|
confirmed_phone: Faker::PhoneNumber.phone_number,
|
||||||
document_number: unique_document_number, document_type: "1")
|
document_number: unique_document_number,
|
||||||
|
document_type: "1")
|
||||||
|
|
||||||
verified = create_user("verified@consul.dev", "verified")
|
verified = create_user("verified@consul.dev", "verified")
|
||||||
verified.update!(residence_verified_at: Time.current,
|
verified.update!(residence_verified_at: Time.current,
|
||||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
confirmed_phone: Faker::PhoneNumber.phone_number,
|
||||||
verified_at: Time.current, document_number: unique_document_number)
|
document_type: "1",
|
||||||
|
verified_at: Time.current,
|
||||||
|
document_number: unique_document_number)
|
||||||
|
|
||||||
[
|
[
|
||||||
I18n.t("seeds.organizations.neighborhood_association"),
|
I18n.t("seeds.organizations.neighborhood_association"),
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ describe "rake db:seed" do
|
|||||||
SiteCustomization::Page.destroy_all
|
SiteCustomization::Page.destroy_all
|
||||||
load Rails.root.join("db", "pages.rb")
|
load Rails.root.join("db", "pages.rb")
|
||||||
|
|
||||||
paths = { accessibility: "pages.accessibility.title", conditions: "pages.conditions.title",
|
paths = { accessibility: "pages.accessibility.title",
|
||||||
faq: "pages.help.faq.page.title", privacy: "pages.privacy.title",
|
conditions: "pages.conditions.title",
|
||||||
|
faq: "pages.help.faq.page.title",
|
||||||
|
privacy: "pages.privacy.title",
|
||||||
welcome_not_verified: "welcome.welcome.title",
|
welcome_not_verified: "welcome.welcome.title",
|
||||||
welcome_level_two_verified: "welcome.welcome.title",
|
welcome_level_two_verified: "welcome.welcome.title",
|
||||||
welcome_level_three_verified: "welcome.welcome.title" }
|
welcome_level_three_verified: "welcome.welcome.title" }
|
||||||
|
|||||||
@@ -522,17 +522,23 @@ describe MachineLearning do
|
|||||||
machine_learning = MachineLearning.new(job)
|
machine_learning = MachineLearning.new(job)
|
||||||
|
|
||||||
tags_data = [
|
tags_data = [
|
||||||
{ id: 0,
|
{
|
||||||
name: "Existing tag" },
|
id: 0,
|
||||||
{ id: 1,
|
name: "Existing tag"
|
||||||
name: "Machine learning tag" }
|
},
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "Machine learning tag"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
taggings_data = [
|
taggings_data = [
|
||||||
{ tag_id: 0,
|
{
|
||||||
|
tag_id: 0,
|
||||||
taggable_id: proposal.id
|
taggable_id: proposal.id
|
||||||
},
|
},
|
||||||
{ tag_id: 1,
|
{
|
||||||
|
tag_id: 1,
|
||||||
taggable_id: proposal.id
|
taggable_id: proposal.id
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -564,17 +570,23 @@ describe MachineLearning do
|
|||||||
machine_learning = MachineLearning.new(job)
|
machine_learning = MachineLearning.new(job)
|
||||||
|
|
||||||
tags_data = [
|
tags_data = [
|
||||||
{ id: 0,
|
{
|
||||||
name: "Existing tag" },
|
id: 0,
|
||||||
{ id: 1,
|
name: "Existing tag"
|
||||||
name: "Machine learning tag" }
|
},
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "Machine learning tag"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
taggings_data = [
|
taggings_data = [
|
||||||
{ tag_id: 0,
|
{
|
||||||
|
tag_id: 0,
|
||||||
taggable_id: investment.id
|
taggable_id: investment.id
|
||||||
},
|
},
|
||||||
{ tag_id: 1,
|
{
|
||||||
|
tag_id: 1,
|
||||||
taggable_id: investment.id
|
taggable_id: investment.id
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -104,44 +104,51 @@ describe Poll do
|
|||||||
|
|
||||||
it "is valid when overlapping but different proposals" do
|
it "is valid when overlapping but different proposals" do
|
||||||
other_proposal = create(:proposal)
|
other_proposal = create(:proposal)
|
||||||
_other_poll = create(:poll, related: other_proposal, starts_at: poll.starts_at,
|
_other_poll = create(:poll, related: other_proposal,
|
||||||
|
starts_at: poll.starts_at,
|
||||||
ends_at: poll.ends_at)
|
ends_at: poll.ends_at)
|
||||||
|
|
||||||
expect(poll).to be_valid
|
expect(poll).to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is valid when same proposal but not overlapping" do
|
it "is valid when same proposal but not overlapping" do
|
||||||
_other_poll = create(:poll, related: proposal, starts_at: poll.ends_at + 1.day,
|
_other_poll = create(:poll, related: proposal,
|
||||||
|
starts_at: poll.ends_at + 1.day,
|
||||||
ends_at: poll.ends_at + 8.days)
|
ends_at: poll.ends_at + 8.days)
|
||||||
expect(poll).to be_valid
|
expect(poll).to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is not valid when overlaps from the beginning" do
|
it "is not valid when overlaps from the beginning" do
|
||||||
_other_poll = create(:poll, related: proposal, starts_at: poll.starts_at - 8.days,
|
_other_poll = create(:poll, related: proposal,
|
||||||
|
starts_at: poll.starts_at - 8.days,
|
||||||
ends_at: poll.starts_at)
|
ends_at: poll.starts_at)
|
||||||
expect(poll).not_to be_valid
|
expect(poll).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is not valid when overlaps from the end" do
|
it "is not valid when overlaps from the end" do
|
||||||
_other_poll = create(:poll, related: proposal, starts_at: poll.ends_at,
|
_other_poll = create(:poll, related: proposal,
|
||||||
|
starts_at: poll.ends_at,
|
||||||
ends_at: poll.ends_at + 8.days)
|
ends_at: poll.ends_at + 8.days)
|
||||||
expect(poll).not_to be_valid
|
expect(poll).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is not valid when overlaps with same interval" do
|
it "is not valid when overlaps with same interval" do
|
||||||
_other_poll = create(:poll, related: proposal, starts_at: poll.starts_at,
|
_other_poll = create(:poll, related: proposal,
|
||||||
|
starts_at: poll.starts_at,
|
||||||
ends_at: poll.ends_at)
|
ends_at: poll.ends_at)
|
||||||
expect(poll).not_to be_valid
|
expect(poll).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is not valid when overlaps with interval contained" do
|
it "is not valid when overlaps with interval contained" do
|
||||||
_other_poll = create(:poll, related: proposal, starts_at: poll.starts_at + 1.day,
|
_other_poll = create(:poll, related: proposal,
|
||||||
|
starts_at: poll.starts_at + 1.day,
|
||||||
ends_at: poll.ends_at - 1.day)
|
ends_at: poll.ends_at - 1.day)
|
||||||
expect(poll).not_to be_valid
|
expect(poll).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is not valid when overlaps with interval containing" do
|
it "is not valid when overlaps with interval containing" do
|
||||||
_other_poll = create(:poll, related: proposal, starts_at: poll.starts_at - 8.days,
|
_other_poll = create(:poll, related: proposal,
|
||||||
|
starts_at: poll.starts_at - 8.days,
|
||||||
ends_at: poll.ends_at + 8.days)
|
ends_at: poll.ends_at + 8.days)
|
||||||
expect(poll).not_to be_valid
|
expect(poll).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ describe Poll::Stats do
|
|||||||
it "supports every channel" do
|
it "supports every channel" do
|
||||||
3.times { create(:poll_voter, :from_web, poll: poll) }
|
3.times { create(:poll_voter, :from_web, poll: poll) }
|
||||||
create(:poll_recount, :from_booth, poll: poll,
|
create(:poll_recount, :from_booth, poll: poll,
|
||||||
total_amount: 8, white_amount: 4, null_amount: 1)
|
total_amount: 8,
|
||||||
|
white_amount: 4,
|
||||||
|
null_amount: 1)
|
||||||
|
|
||||||
expect(stats.total_participants_web).to eq(3)
|
expect(stats.total_participants_web).to eq(3)
|
||||||
expect(stats.total_participants_booth).to eq(13)
|
expect(stats.total_participants_booth).to eq(13)
|
||||||
@@ -153,7 +155,9 @@ describe Poll::Stats do
|
|||||||
it "is relative to the total amount of votes" do
|
it "is relative to the total amount of votes" do
|
||||||
3.times { create(:poll_voter, :from_web, poll: poll) }
|
3.times { create(:poll_voter, :from_web, poll: poll) }
|
||||||
create(:poll_recount, :from_booth, poll: poll,
|
create(:poll_recount, :from_booth, poll: poll,
|
||||||
total_amount: 8, white_amount: 5, null_amount: 4)
|
total_amount: 8,
|
||||||
|
white_amount: 5,
|
||||||
|
null_amount: 4)
|
||||||
|
|
||||||
expect(stats.total_valid_percentage).to eq(50)
|
expect(stats.total_valid_percentage).to eq(50)
|
||||||
expect(stats.total_white_percentage).to eq(30)
|
expect(stats.total_white_percentage).to eq(30)
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ describe "Admin budget investments", :admin do
|
|||||||
admin = create(:administrator, user: create(:user, username: "Gema"))
|
admin = create(:administrator, user: create(:user, username: "Gema"))
|
||||||
|
|
||||||
budget_investment1 = create(:budget_investment, budget: budget, valuators: [valuator1])
|
budget_investment1 = create(:budget_investment, budget: budget, valuators: [valuator1])
|
||||||
budget_investment2 = create(:budget_investment, budget: budget, valuators: [valuator1, valuator2],
|
budget_investment2 = create(:budget_investment, budget: budget,
|
||||||
|
valuators: [valuator1, valuator2],
|
||||||
valuator_groups: [valuator_group])
|
valuator_groups: [valuator_group])
|
||||||
budget_investment3 = create(:budget_investment, budget: budget)
|
budget_investment3 = create(:budget_investment, budget: budget)
|
||||||
|
|
||||||
@@ -147,7 +148,8 @@ describe "Admin budget investments", :admin do
|
|||||||
administrator = create(:administrator, user: user)
|
administrator = create(:administrator, user: user)
|
||||||
administrator2 = create(:administrator, user: user2, description: "Alias")
|
administrator2 = create(:administrator, user: user2, description: "Alias")
|
||||||
budget.administrators = [administrator, administrator2]
|
budget.administrators = [administrator, administrator2]
|
||||||
create(:budget_investment, title: "Realocate visitors", budget: budget,
|
create(:budget_investment, title: "Realocate visitors",
|
||||||
|
budget: budget,
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
create(:budget_investment, title: "Destroy the city", budget: budget)
|
create(:budget_investment, title: "Destroy the city", budget: budget)
|
||||||
|
|
||||||
@@ -400,7 +402,8 @@ describe "Admin budget investments", :admin do
|
|||||||
scenario "Filtering by assignment status" do
|
scenario "Filtering by assignment status" do
|
||||||
create(:budget_investment, :with_administrator, title: "Assigned idea", budget: budget)
|
create(:budget_investment, :with_administrator, title: "Assigned idea", budget: budget)
|
||||||
create(:budget_investment, :with_valuator, title: "Evaluating...", budget: budget)
|
create(:budget_investment, :with_valuator, title: "Evaluating...", budget: budget)
|
||||||
create(:budget_investment, title: "With group", budget: budget,
|
create(:budget_investment, title: "With group",
|
||||||
|
budget: budget,
|
||||||
valuator_groups: [create(:valuator_group)])
|
valuator_groups: [create(:valuator_group)])
|
||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget_id: budget.id, filter: "valuation_open")
|
visit admin_budget_budget_investments_path(budget_id: budget.id, filter: "valuation_open")
|
||||||
@@ -613,7 +616,8 @@ describe "Admin budget investments", :admin do
|
|||||||
administrator = create(:administrator, user: user)
|
administrator = create(:administrator, user: user)
|
||||||
budget.administrators = [administrator]
|
budget.administrators = [administrator]
|
||||||
|
|
||||||
educate_children = create(:budget_investment, budget: budget, title: "Educate the children",
|
educate_children = create(:budget_investment, budget: budget,
|
||||||
|
title: "Educate the children",
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
create(:budget_investment, budget: budget, title: "More schools",
|
create(:budget_investment, budget: budget, title: "More schools",
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
@@ -686,7 +690,8 @@ describe "Admin budget investments", :admin do
|
|||||||
|
|
||||||
educate_children = create(:budget_investment, :feasible, :finished,
|
educate_children = create(:budget_investment, :feasible, :finished,
|
||||||
budget: budget, title: "Educate the children", administrator: administrator)
|
budget: budget, title: "Educate the children", administrator: administrator)
|
||||||
create(:budget_investment, :feasible, :finished, budget: budget, title: "More schools",
|
create(:budget_investment, :feasible, :finished, budget: budget,
|
||||||
|
title: "More schools",
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
create(:budget_investment, budget: budget, title: "More hospitals",
|
create(:budget_investment, budget: budget, title: "More hospitals",
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
|
|||||||
@@ -452,7 +452,8 @@ describe "Admin budgets", :admin do
|
|||||||
scenario "For a Budget in reviewing balloting" do
|
scenario "For a Budget in reviewing balloting" do
|
||||||
budget = create(:budget, :reviewing_ballots)
|
budget = create(:budget, :reviewing_ballots)
|
||||||
heading = create(:budget_heading, budget: budget, price: 4)
|
heading = create(:budget_heading, budget: budget, price: 4)
|
||||||
unselected = create(:budget_investment, :unselected, heading: heading, price: 1,
|
unselected = create(:budget_investment, :unselected, heading: heading,
|
||||||
|
price: 1,
|
||||||
ballot_lines_count: 3)
|
ballot_lines_count: 3)
|
||||||
winner = create(:budget_investment, :selected, heading: heading, price: 3,
|
winner = create(:budget_investment, :selected, heading: heading, price: 3,
|
||||||
ballot_lines_count: 2)
|
ballot_lines_count: 2)
|
||||||
|
|||||||
@@ -154,12 +154,14 @@ describe "Proposal's dashboard" do
|
|||||||
|
|
||||||
requested = create(:dashboard_action, :resource, :admin_request, :active)
|
requested = create(:dashboard_action, :resource, :admin_request, :active)
|
||||||
executed_action = create(:dashboard_executed_action, action: requested,
|
executed_action = create(:dashboard_executed_action, action: requested,
|
||||||
proposal: proposal, executed_at: Time.current)
|
proposal: proposal,
|
||||||
|
executed_at: Time.current)
|
||||||
_task = create(:dashboard_administrator_task, :pending, source: executed_action)
|
_task = create(:dashboard_administrator_task, :pending, source: executed_action)
|
||||||
|
|
||||||
solved = create(:dashboard_action, :resource, :admin_request, :active)
|
solved = create(:dashboard_action, :resource, :admin_request, :active)
|
||||||
executed_solved_action = create(:dashboard_executed_action, action: solved,
|
executed_solved_action = create(:dashboard_executed_action, action: solved,
|
||||||
proposal: proposal, executed_at: Time.current)
|
proposal: proposal,
|
||||||
|
executed_at: Time.current)
|
||||||
_solved_task = create(:dashboard_administrator_task, :done, source: executed_solved_action)
|
_solved_task = create(:dashboard_administrator_task, :done, source: executed_solved_action)
|
||||||
|
|
||||||
unavailable = create(:dashboard_action, :resource, :active,
|
unavailable = create(:dashboard_action, :resource, :active,
|
||||||
@@ -199,12 +201,14 @@ describe "Proposal's dashboard" do
|
|||||||
|
|
||||||
requested = create(:dashboard_action, :resource, :admin_request, :active)
|
requested = create(:dashboard_action, :resource, :admin_request, :active)
|
||||||
executed_action = create(:dashboard_executed_action, action: requested,
|
executed_action = create(:dashboard_executed_action, action: requested,
|
||||||
proposal: proposal, executed_at: Time.current)
|
proposal: proposal,
|
||||||
|
executed_at: Time.current)
|
||||||
_task = create(:dashboard_administrator_task, :pending, source: executed_action)
|
_task = create(:dashboard_administrator_task, :pending, source: executed_action)
|
||||||
|
|
||||||
solved = create(:dashboard_action, :resource, :admin_request, :active)
|
solved = create(:dashboard_action, :resource, :admin_request, :active)
|
||||||
executed_solved_action = create(:dashboard_executed_action, action: solved,
|
executed_solved_action = create(:dashboard_executed_action, action: solved,
|
||||||
proposal: proposal, executed_at: Time.current)
|
proposal: proposal,
|
||||||
|
executed_at: Time.current)
|
||||||
_solved_task = create(:dashboard_administrator_task, :done, source: executed_solved_action)
|
_solved_task = create(:dashboard_administrator_task, :done, source: executed_solved_action)
|
||||||
|
|
||||||
unavailable = create(:dashboard_action, :resource, :active,
|
unavailable = create(:dashboard_action, :resource, :active,
|
||||||
|
|||||||
@@ -202,7 +202,8 @@ describe "Valuation budget investments" do
|
|||||||
create(:valuator, user: create(:user, username: "Rick", email: "rick@valuators.org"))
|
create(:valuator, user: create(:user, username: "Rick", email: "rick@valuators.org"))
|
||||||
end
|
end
|
||||||
let(:investment) do
|
let(:investment) do
|
||||||
create(:budget_investment, :unfeasible, budget: budget, price: 1234,
|
create(:budget_investment, :unfeasible, budget: budget,
|
||||||
|
price: 1234,
|
||||||
unfeasibility_explanation: "It is impossible",
|
unfeasibility_explanation: "It is impossible",
|
||||||
administrator: administrator,
|
administrator: administrator,
|
||||||
valuators: [valuator, second_valuator])
|
valuators: [valuator, second_valuator])
|
||||||
|
|||||||
Reference in New Issue
Block a user