Attention ! Gitlab fournissant maintenant nativement des certificats Let’s Encrypt aux domaines personnalisés des Gitlab Pages, nous avons coupé notre service qui le faisait automatiquement pour vous.

Il est impératif, pour que votre domaine personnalisé continue à avoir un certificat Let’s Encrypt à jour, d’activer la fonctionnalité native dans les paramètres de votre projet. Cette activation remplacera votre certificat actuel par un nouveau certificat Let’s Encrypt géré par Gitlab.

Voir les détails sur https://docs.framasoft.org/fr/gitlab/gitlab-pages-le.html

Commit 27d551d2 authored by Alexandre Friquet's avatar Alexandre Friquet

Use new season birthdate for event types and activities: refs #89.

parent b2dab4e4
......@@ -47,7 +47,7 @@ class Activity < ApplicationRecord
result = {}
self.events.visible.chronology.each do |event|
year = event.begin_at.year
if event.begin_at >= Date.new(year,8,15)
if event.begin_at >= Season.birthdate.change(year: year)
(result["Saison #{year.to_s}-#{(year+1).to_s}"] ||= []) << event
else
(result["Saison #{(year-1).to_s}-#{year.to_s}"] ||= []) << event
......
......@@ -57,7 +57,7 @@ class EventType < ApplicationRecord
result = {}
self.events.with_dates.visible.reverse_chronology.each do |event|
year = event.begin_at.year
if event.begin_at >= Date.new(year,8,15)
if event.begin_at >= Season.birthdate.change(year: year)
(result["Saison #{year.to_s}-#{(year+1).to_s}"] ||= []) << event
else
(result["Saison #{(year-1).to_s}-#{year.to_s}"] ||= []) << event
......
......@@ -28,9 +28,13 @@ class Season
Date.new(1970,FIRST_MONTH, FIRST_DAY)
end
def self.birthdate
Settings.instance.reload.season_birthdate || self.default_birthdate
end
def initialize(date)
year = (date < Date.new(date.year, FIRST_MONTH, FIRST_DAY) ? date.year-1 : date.year)
@begining = Date.new(year, FIRST_MONTH, FIRST_DAY)
year = (date < Season.birthdate.change(year: date.year) ? date.year-1 : date.year)
@begining = Season.birthdate.change(year: year)
return self
end
......
......@@ -23,19 +23,73 @@
require 'rails_helper'
RSpec.describe Season, type: :model do
context "regarding initialization" do
context "sets the begining ot the season to" do
scenario "15/08/2017 when date 19/09/2017 is given" do
season = Season.new(Date.new(2017,9,19))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2017,8,15)
context "class methods" do
it ".default_birthdate set to 15/08/1970" do
# Given
# When
result = Season.default_birthdate
# Then
expect(result).to eq Date.new(1970,8,15)
end
context ".birthdate" do
it "return 15/08/1970 when season birthdate not provided" do
# Given
# When
result = Season.birthdate
# Then
expect(result).to eq Date.new(1970,8,15)
end
scenario "15/08/2017 when date 15/08/2017 is given" do
season = Season.new(Date.new(2017,8,15))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2017,8,15)
it "returns season birthdate when provided" do
# Given
first_of_september = Date.new(1970,9,1)
@settings.update_attribute(:season_birthdate, first_of_september)
# When
result = Season.birthdate
# Then
expect(result).to eq first_of_september
end
scenario "15/08/2016 when date 14/08/2017 is given" do
season = Season.new(Date.new(2017,8,14))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2016,8,15)
end
end
context "regarding initialization" do
context "when season birthdate not provided" do
context "sets the begining ot the season to" do
scenario "15/08/2017 when date 19/09/2017 is given" do
season = Season.new(Date.new(2017,9,19))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2017,8,15)
end
scenario "15/08/2017 when date 15/08/2017 is given" do
season = Season.new(Date.new(2017,8,15))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2017,8,15)
end
scenario "15/08/2016 when date 14/08/2017 is given" do
season = Season.new(Date.new(2017,8,14))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2016,8,15)
end
end
end
context "when season birthdate set to 01/09/1970" do
before { @settings.update_attribute(:season_birthdate, Date.new(1970,9,1)) }
context "sets the begining ot the season to" do
scenario "01/09/2017 when date 19/09/2017 is given" do
season = Season.new(Date.new(2017,9,19))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2017,9,1)
end
scenario "01/09/2017 when date 01/09/2017 is given" do
season = Season.new(Date.new(2017,9,1))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2017,9,1)
end
scenario "01/09/2016 when date 31/08/2017 is given" do
season = Season.new(Date.new(2017,8,31))
expect(season.instance_variable_get(:@begining)).to eq Date.new(2016,9,1)
end
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment