Commit b3a72733 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira 🌴

Merge branch 'fix_team_start_dates' into 'master'

Fix team start dates

See merge request !16872
parents a0d0217a cee55722
Pipeline #40020882 passed with stages
in 20 minutes and 50 seconds
......@@ -2,6 +2,7 @@ require 'scss_lint/rake_task'
require 'yaml'
require 'stringex'
require_relative './lib/competitor.rb'
require_relative './lib/team.rb'
desc 'Run all lint tasks'
task lint: ['lint:scss',
......@@ -12,6 +13,7 @@ task lint: ['lint:scss',
'lint:team_yml:pictures',
'lint:team_yml:unique',
'lint:team_yml:roles',
'lint:team_yml:start_dates',
'lint:docs_ee',
'lint:features:links'] do
end
......@@ -292,6 +294,26 @@ namespace :lint do
puts 'All pictures referenced in data/team.yml exist!'
end
desc "Ensure start_date in data/team.yml is valid"
task :start_dates do
puts ''
puts '=> Checking all start dates in data/team.yml are valid'
members_with_invalid_start_dates = Gitlab::Homepage::Team.new.members_with_invalid_start_dates
if members_with_invalid_start_dates.any?
message = members_with_invalid_start_dates.map { |member| "\t#{member.name} => #{member.start_date}" }.join("\n")
puts '----------------------------'
puts "Oops! It seems like one or multiple start_date in data/team.yml are invalid:"
puts message
puts "Please check that each start_date is a valid date in the YYYY-MM-DD format."
exit 1
end
puts 'All start dates in data/team.yml are valid!'
end
end
desc "Check that all docs point to /ee/"
......
require 'yaml'
require_relative './team/member'
module Gitlab
module Homepage
......@@ -11,6 +12,12 @@ module Gitlab
end
end
def members_with_invalid_start_dates
Team::Member.all!.reject do |member|
member.start_date.nil? || member.start_date.is_a?(Date)
end
end
def projects
@projects ||= Team::Project.all! do |project|
Team::Member.all! do |member|
......
......@@ -16,12 +16,12 @@ module Gitlab
end
end
def <=>(other)
sort_ordering = (start_date.nil? ? Date.today : start_date) <=> (other.start_date.nil? ? Date.today : other.start_date)
return 0 if sort_ordering.nil?
def valid_start_date?
start_date.nil? || start_date.is_a?(Date)
end
sort_ordering
def <=>(other)
(start_date.nil? ? Date.today : start_date) <=> (other.start_date.nil? ? Date.today : other.start_date)
end
def ==(other)
......
......@@ -12,6 +12,10 @@ describe Gitlab::Homepage::Team::Member do
it 'correctly loads report titles' do
expect(subject.first.reports_to_title).to match('CEO')
end
it 'sorts live team data without errors' do
expect { subject.sort }.not_to raise_error
end
end
describe '.no_vacancies' do
......@@ -37,6 +41,18 @@ describe Gitlab::Homepage::Team::Member do
end
end
describe '<=>' do
let(:member_a) { described_class.new('slug' => 'a', 'start_date' => Date.new(2012, 1, 1)) }
let(:member_b) { described_class.new('slug' => 'b', 'start_date' => Date.new(2018, 7, 1)) }
let(:vacancy) { described_class.new('slug' => 'vacancy', 'start_date' => nil, 'type' => 'vacancy') }
let(:vacancy_with_start_date) { described_class.new('slug' => 'vacancy_b', 'start_date' => Date.new(2018, 1, 1), 'type' => 'vacancy') }
let(:members) { [vacancy_with_start_date, vacancy, member_b, member_a] }
it 'sorts by start date' do
expect(members.sort).to eq([member_a, vacancy_with_start_date, member_b, vacancy])
end
end
describe '#hash' do
it 'returns the slug' do
member_a = described_class.new('slug' => 'a')
......
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