Enhancements and bugfixing

FIxed issue in last commit: supports controller were not correctly
filling the holes without data.

Fixed duplication in supports and successful supports controller using a
concer.

Successfull supports controller will fill the holes without data in the
same way that supports controller does.
This commit is contained in:
Juan Salvador Pérez García
2018-09-14 11:30:59 +02:00
parent 3590657777
commit 0bd381aa5e
5 changed files with 73 additions and 81 deletions

View File

@@ -1,8 +1,8 @@
require 'rails_helper'
describe "Retrieves number of supports for the successful proposal" do
let(:created_at) { DateTime.parse("2018-01-01 12:00:00") }
let(:proposal) { create(:proposal, created_at: created_at) }
let(:created_at) { Time.now.beginning_of_day - 9.days }
let(:proposal) { create(:proposal, created_at: created_at, published_at: created_at) }
before do
@successful_proposal_id = Setting['proposals.successful_proposal_id']
@@ -32,7 +32,7 @@ describe "Retrieves number of supports for the successful proposal" do
json = JSON.parse(response.body, symbolize_names: true)
expect(response).to have_http_status(200)
expect(json.length).to eq(8)
expect(json.length).to eq(10)
expect(json.values.last).to eq(8)
end
@@ -52,7 +52,8 @@ describe "Retrieves number of supports for the successful proposal" do
json = JSON.parse(response.body, symbolize_names: true)
expect(response).to have_http_status(200)
expect(json.length).to eq(1)
expect(json.length).to be >= 1
expect(json.length).to be <= 2
expect(json.values.last).to eq(8)
end
end

View File

@@ -1,7 +1,7 @@
require 'rails_helper'
describe "Retrieves number of supports for a proposal" do
let(:created_at) { DateTime.parse("2018-01-01 12:00:00") }
let(:created_at) { Time.now - 9.days }
let(:proposal) { create(:proposal, created_at: created_at, published_at: created_at) }
before do
@@ -19,7 +19,7 @@ describe "Retrieves number of supports for a proposal" do
json = JSON.parse(response.body, symbolize_names: true)
expect(response).to have_http_status(200)
expect(json.length).to eq(8)
expect(json.length).to eq(10)
expect(json.values.last).to eq(8)
end
@@ -39,7 +39,8 @@ describe "Retrieves number of supports for a proposal" do
json = JSON.parse(response.body, symbolize_names: true)
expect(response).to have_http_status(200)
expect(json.length).to eq(1)
expect(json.length).to be >= 1
expect(json.length).to be <= 2
expect(json.values.last).to eq(8)
end
end