Remove people proposal model
This model isn't used anywhere, since it was created as part of a
feature which couldn't be completed.
This commit reverts commit 46e5d6a9.
This commit is contained in:
@@ -13,13 +13,10 @@ FactoryBot.define do
|
||||
allegations_end_date { Date.current + 3.days }
|
||||
proposals_phase_start_date { Date.current }
|
||||
proposals_phase_end_date { Date.current + 2.days }
|
||||
people_proposals_phase_start_date { Date.current }
|
||||
people_proposals_phase_end_date { Date.current + 2.days }
|
||||
result_publication_date { Date.current + 5.days }
|
||||
debate_phase_enabled { true }
|
||||
allegations_phase_enabled { true }
|
||||
proposals_phase_enabled { true }
|
||||
people_proposals_phase_enabled { true }
|
||||
draft_publication_enabled { true }
|
||||
result_publication_enabled { true }
|
||||
published { true }
|
||||
@@ -66,18 +63,6 @@ FactoryBot.define do
|
||||
proposals_phase_enabled { true }
|
||||
end
|
||||
|
||||
trait :in_people_proposals_phase do
|
||||
people_proposals_phase_start_date { Date.current - 1.day }
|
||||
people_proposals_phase_end_date { Date.current + 2.days }
|
||||
people_proposals_phase_enabled { true }
|
||||
end
|
||||
|
||||
trait :upcoming_people_proposals_phase do
|
||||
people_proposals_phase_start_date { Date.current + 1.day }
|
||||
people_proposals_phase_end_date { Date.current + 2.days }
|
||||
people_proposals_phase_enabled { true }
|
||||
end
|
||||
|
||||
trait :published do
|
||||
published { true }
|
||||
end
|
||||
@@ -101,13 +86,10 @@ FactoryBot.define do
|
||||
allegations_end_date { nil }
|
||||
proposals_phase_start_date { nil }
|
||||
proposals_phase_end_date { nil }
|
||||
people_proposals_phase_start_date { nil }
|
||||
people_proposals_phase_end_date { nil }
|
||||
result_publication_date { nil }
|
||||
debate_phase_enabled { false }
|
||||
allegations_phase_enabled { false }
|
||||
proposals_phase_enabled { false }
|
||||
people_proposals_phase_enabled { false }
|
||||
draft_publication_enabled { false }
|
||||
result_publication_enabled { false }
|
||||
published { true }
|
||||
@@ -183,27 +165,4 @@ FactoryBot.define do
|
||||
process factory: :legislation_process
|
||||
author factory: :user
|
||||
end
|
||||
|
||||
factory :legislation_people_proposal, class: "Legislation::PeopleProposal" do
|
||||
sequence(:title) { |n| "People and group #{n} for a legislation" }
|
||||
summary { "This law should be implemented by..." }
|
||||
terms_of_service { "1" }
|
||||
process factory: :legislation_process
|
||||
author factory: :user
|
||||
validated { false }
|
||||
|
||||
trait :with_contact_info do
|
||||
email { "proposal@test.com" }
|
||||
website { "https://proposal.io" }
|
||||
phone { "666666666" }
|
||||
facebook { "facebook.id" }
|
||||
twitter { "TwitterId" }
|
||||
youtube { "youtubechannelid" }
|
||||
instagram { "instagramid" }
|
||||
end
|
||||
|
||||
trait :validated do
|
||||
validated { true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Legislation::PeopleProposal do
|
||||
let(:people_proposal) { build(:legislation_people_proposal) }
|
||||
|
||||
it "is valid" do
|
||||
expect(people_proposal).to be_valid
|
||||
end
|
||||
|
||||
it "is not valid without a process" do
|
||||
people_proposal.process = nil
|
||||
expect(people_proposal).not_to be_valid
|
||||
end
|
||||
|
||||
it "is not valid without an author" do
|
||||
people_proposal.author = nil
|
||||
expect(people_proposal).not_to be_valid
|
||||
end
|
||||
|
||||
it "is not valid without a title" do
|
||||
people_proposal.title = nil
|
||||
expect(people_proposal).not_to be_valid
|
||||
end
|
||||
|
||||
it "is not valid without a summary" do
|
||||
people_proposal.summary = nil
|
||||
expect(people_proposal).not_to be_valid
|
||||
end
|
||||
|
||||
describe "#hot_score" do
|
||||
let(:now) { Time.current }
|
||||
|
||||
it "period is correctly calculated to get exact votes per day" do
|
||||
new_people_proposal = create(:legislation_people_proposal, created_at: 23.hours.ago)
|
||||
2.times { new_people_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
expect(new_people_proposal.hot_score).to be 2
|
||||
|
||||
old_people_proposal = create(:legislation_people_proposal, created_at: 25.hours.ago)
|
||||
2.times { old_people_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
expect(old_people_proposal.hot_score).to be 1
|
||||
|
||||
older_people_proposal = create(:legislation_people_proposal, created_at: 49.hours.ago)
|
||||
3.times { older_people_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
expect(old_people_proposal.hot_score).to be 1
|
||||
end
|
||||
|
||||
it "remains the same for not voted people_proposals" do
|
||||
new = create(:legislation_people_proposal, created_at: now)
|
||||
old = create(:legislation_people_proposal, created_at: 1.day.ago)
|
||||
older = create(:legislation_people_proposal, created_at: 2.months.ago)
|
||||
expect(new.hot_score).to be 0
|
||||
expect(old.hot_score).to be 0
|
||||
expect(older.hot_score).to be 0
|
||||
end
|
||||
|
||||
it "increases for people_proposals with more positive votes" do
|
||||
more_positive_votes = create(:legislation_people_proposal)
|
||||
2.times { more_positive_votes.vote_by(voter: create(:user), vote: "yes") }
|
||||
|
||||
less_positive_votes = create(:legislation_people_proposal)
|
||||
less_positive_votes.vote_by(voter: create(:user), vote: "yes")
|
||||
|
||||
expect(more_positive_votes.hot_score).to be > less_positive_votes.hot_score
|
||||
end
|
||||
|
||||
it "increases for people_proposals with the same amount of positive votes within less days" do
|
||||
newer_people_proposal = create(:legislation_people_proposal, created_at: now)
|
||||
5.times { newer_people_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
|
||||
older_people_proposal = create(:legislation_people_proposal, created_at: 1.day.ago)
|
||||
5.times { older_people_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
|
||||
expect(newer_people_proposal.hot_score).to be > older_people_proposal.hot_score
|
||||
end
|
||||
|
||||
it "increases for people_proposals voted within the period (last month by default)" do
|
||||
newer_people_proposal = create(:legislation_people_proposal, created_at: 2.months.ago)
|
||||
20.times { create(:vote, votable: newer_people_proposal, created_at: 3.days.ago) }
|
||||
|
||||
older_people_proposal = create(:legislation_people_proposal, created_at: 2.months.ago)
|
||||
20.times { create(:vote, votable: older_people_proposal, created_at: 40.days.ago) }
|
||||
|
||||
expect(newer_people_proposal.hot_score).to be > older_people_proposal.hot_score
|
||||
end
|
||||
|
||||
describe "actions which affect it" do
|
||||
let(:people_proposal) { create(:legislation_people_proposal) }
|
||||
|
||||
before do
|
||||
5.times { people_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
2.times { people_proposal.vote_by(voter: create(:user), vote: "no") }
|
||||
end
|
||||
|
||||
it "increases with positive votes" do
|
||||
previous = people_proposal.hot_score
|
||||
3.times { people_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
expect(previous).to be < people_proposal.hot_score
|
||||
end
|
||||
|
||||
it "decreases with negative votes" do
|
||||
previous = people_proposal.hot_score
|
||||
3.times { people_proposal.vote_by(voter: create(:user), vote: "no") }
|
||||
expect(previous).to be > people_proposal.hot_score
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user