Adding consistency for post_started_at and post_ended_at on specs

These two fields are of type Date and in some specs they are being
filled as Time or DateTime.
This commit is contained in:
taitus
2021-04-08 16:52:57 +02:00
parent 408422891e
commit 85611a5103
4 changed files with 24 additions and 24 deletions

View File

@@ -6,8 +6,8 @@ describe Shared::BannerComponent, type: :component do
title: "Vote now!", title: "Vote now!",
description: "Banner description", description: "Banner description",
target_url: "http://www.url.com", target_url: "http://www.url.com",
post_started_at: (Time.current - 4.days), post_started_at: (Date.current - 4.days),
post_ended_at: (Time.current + 10.days), post_ended_at: (Date.current + 10.days),
background_color: "#FF0000", background_color: "#FF0000",
font_color: "#FFFFFF" font_color: "#FFFFFF"
) )
@@ -69,7 +69,7 @@ describe Shared::BannerComponent, type: :component do
end end
it "only renders active banners" do it "only renders active banners" do
Banner.first.update!(post_ended_at: 1.day.ago) Banner.first.update!(post_ended_at: Date.current - 1.day)
render_inline Shared::BannerComponent.new("debates") render_inline Shared::BannerComponent.new("debates")
@@ -78,7 +78,7 @@ describe Shared::BannerComponent, type: :component do
end end
it "does not render anything with no active banners" do it "does not render anything with no active banners" do
Banner.all.each { |banner| banner.update!(post_ended_at: 1.day.ago) } Banner.all.each { |banner| banner.update!(post_ended_at: Date.current - 1.day) }
render_inline Shared::BannerComponent.new("debates") render_inline Shared::BannerComponent.new("debates")

View File

@@ -18,8 +18,8 @@ FactoryBot.define do
sequence(:title) { |n| "Banner title #{n}" } sequence(:title) { |n| "Banner title #{n}" }
sequence(:description) { |n| "This is the text of Banner #{n}" } sequence(:description) { |n| "This is the text of Banner #{n}" }
target_url { ["/proposals", "/debates"].sample } target_url { ["/proposals", "/debates"].sample }
post_started_at { Time.current - 7.days } post_started_at { Date.current - 7.days }
post_ended_at { Time.current + 7.days } post_ended_at { Date.current + 7.days }
background_color { "#FF0000" } background_color { "#FF0000" }
font_color { "#FFFFFF" } font_color { "#FFFFFF" }
end end

View File

@@ -6,40 +6,40 @@ describe "Admin banners magement", :admin do
create(:banner, title: "Banner number one", create(:banner, title: "Banner number one",
description: "This is the text of banner number one and is not active yet", description: "This is the text of banner number one and is not active yet",
target_url: "http://www.url.com", target_url: "http://www.url.com",
post_started_at: (Time.current + 4.days), post_started_at: (Date.current + 4.days),
post_ended_at: (Time.current + 10.days), post_ended_at: (Date.current + 10.days),
background_color: "#FF0000", background_color: "#FF0000",
font_color: "#FFFFFF") font_color: "#FFFFFF")
create(:banner, title: "Banner number two", create(:banner, title: "Banner number two",
description: "This is the text of banner number two and is not longer active", description: "This is the text of banner number two and is not longer active",
target_url: "http://www.url.com", target_url: "http://www.url.com",
post_started_at: (Time.current - 10.days), post_started_at: (Date.current - 10.days),
post_ended_at: (Time.current - 3.days), post_ended_at: (Date.current - 3.days),
background_color: "#00FF00", background_color: "#00FF00",
font_color: "#FFFFFF") font_color: "#FFFFFF")
create(:banner, title: "Banner number three", create(:banner, title: "Banner number three",
description: "This is the text of banner number three", description: "This is the text of banner number three",
target_url: "http://www.url.com", target_url: "http://www.url.com",
post_started_at: (Time.current - 1.day), post_started_at: (Date.current - 1.day),
post_ended_at: (Time.current + 10.days), post_ended_at: (Date.current + 10.days),
background_color: "#0000FF", background_color: "#0000FF",
font_color: "#FFFFFF") font_color: "#FFFFFF")
create(:banner, title: "Banner number four", create(:banner, title: "Banner number four",
description: "This is the text of banner number four", description: "This is the text of banner number four",
target_url: "http://www.url.com", target_url: "http://www.url.com",
post_started_at: (DateTime.current - 10.days), post_started_at: (Date.current - 10.days),
post_ended_at: (DateTime.current + 10.days), post_ended_at: (Date.current + 10.days),
background_color: "#FFF000", background_color: "#FFF000",
font_color: "#FFFFFF") font_color: "#FFFFFF")
create(:banner, title: "Banner number five", create(:banner, title: "Banner number five",
description: "This is the text of banner number five", description: "This is the text of banner number five",
target_url: "http://www.url.com", target_url: "http://www.url.com",
post_started_at: (DateTime.current - 10.days), post_started_at: (Date.current - 10.days),
post_ended_at: (DateTime.current + 10.days), post_ended_at: (Date.current + 10.days),
background_color: "#FFFF00", background_color: "#FFFF00",
font_color: "#FFFFFF") font_color: "#FFFFFF")
end end
@@ -100,8 +100,8 @@ describe "Admin banners magement", :admin do
fill_in "Title", with: "En Français" fill_in "Title", with: "En Français"
fill_in "Description", with: "Link en Français" fill_in "Description", with: "Link en Français"
fill_in "Link", with: "https://www.url.com" fill_in "Link", with: "https://www.url.com"
fill_in "Post started at", with: Time.current - 1.week fill_in "Post started at", with: Date.current - 1.week
fill_in "Post ended at", with: Time.current + 1.week fill_in "Post ended at", with: Date.current + 1.week
click_button "Save changes" click_button "Save changes"
click_link "Edit banner" click_link "Edit banner"
@@ -125,8 +125,8 @@ describe "Admin banners magement", :admin do
create(:banner, title: "Hello", create(:banner, title: "Hello",
description: "Wrong text", description: "Wrong text",
target_url: "http://www.url.com", target_url: "http://www.url.com",
post_started_at: (Time.current + 4.days), post_started_at: (Date.current + 4.days),
post_ended_at: (Time.current + 10.days), post_ended_at: (Date.current + 10.days),
background_color: "#FF0000", background_color: "#FF0000",
font_color: "#FFFFFF") font_color: "#FFFFFF")
@@ -164,8 +164,8 @@ describe "Admin banners magement", :admin do
create(:banner, title: "Ugly banner", create(:banner, title: "Ugly banner",
description: "Bad text", description: "Bad text",
target_url: "http://www.url.com", target_url: "http://www.url.com",
post_started_at: (Time.current + 4.days), post_started_at: (Date.current + 4.days),
post_ended_at: (Time.current + 10.days), post_ended_at: (Date.current + 10.days),
background_color: "#FF0000", background_color: "#FF0000",
font_color: "#FFFFFF") font_color: "#FFFFFF")

View File

@@ -5,8 +5,8 @@ describe "Banner" do
create(:banner, create(:banner,
web_sections: [WebSection.find_by!(name: "homepage")], web_sections: [WebSection.find_by!(name: "homepage")],
description: "Banner description", description: "Banner description",
post_started_at: (Time.current - 4.days), post_started_at: (Date.current - 4.days),
post_ended_at: (Time.current + 10.days)) post_ended_at: (Date.current + 10.days))
visit root_path visit root_path