Merge branch 'stable' into develop

This commit is contained in:
Steffen van Bergerem 2016-03-30 11:13:47 +02:00
commit c8a8110cf1
4 changed files with 22 additions and 9 deletions

View file

@ -146,6 +146,7 @@ Contributions are very welcome, the hard work is done!
* Fix internal server error when trying to log out of an expired session [#6707](https://github.com/diaspora/diaspora/pull/6707) * Fix internal server error when trying to log out of an expired session [#6707](https://github.com/diaspora/diaspora/pull/6707)
* Only mark unread notifications as read [#6711](https://github.com/diaspora/diaspora/pull/6711) * Only mark unread notifications as read [#6711](https://github.com/diaspora/diaspora/pull/6711)
* Use https for OEmbeds [#6748](https://github.com/diaspora/diaspora/pull/6748) * Use https for OEmbeds [#6748](https://github.com/diaspora/diaspora/pull/6748)
* Fix birthday issues on leap days [#6738](https://github.com/diaspora/diaspora/pull/6738)
## Features ## Features
* Added the footer to conversation pages [#6710](https://github.com/diaspora/diaspora/pull/6710) * Added the footer to conversation pages [#6710](https://github.com/diaspora/diaspora/pull/6710)

View file

@ -16,10 +16,10 @@ module PeopleHelper
end end
def birthday_format(bday) def birthday_format(bday)
if bday.year == 1000 if bday.year <= 1004
I18n.l bday, :format => I18n.t('date.formats.birthday') I18n.l bday, format: I18n.t("date.formats.birthday")
else else
I18n.l bday, :format => I18n.t('date.formats.birthday_with_year') I18n.l bday, format: I18n.t("date.formats.birthday_with_year")
end end
end end

View file

@ -113,20 +113,20 @@ class Profile < ActiveRecord::Base
end end
def date= params def date= params
if ['month', 'day'].all? { |key| params[key].present? } if %w(month day).all? {|key| params[key].present? }
params['year'] = '1000' if params['year'].blank? params["year"] = "1004" if params["year"].blank?
if Date.valid_civil?(params['year'].to_i, params['month'].to_i, params['day'].to_i) if Date.valid_civil?(params["year"].to_i, params["month"].to_i, params["day"].to_i)
self.birthday = Date.new(params['year'].to_i, params['month'].to_i, params['day'].to_i) self.birthday = Date.new(params["year"].to_i, params["month"].to_i, params["day"].to_i)
else else
@invalid_birthday_date = true @invalid_birthday_date = true
end end
elsif [ 'year', 'month', 'day'].all? { |key| params[key].blank? } elsif %w(year month day).all? {|key| params[key].blank? }
self.birthday = nil self.birthday = nil
end end
end end
def formatted_birthday def formatted_birthday
birthday.to_s(:long).gsub(', 1000', '') if birthday.present? birthday.to_s(:long).gsub(/, 100[0|4]/, "") if birthday.present?
end end
def bio_message def bio_message

View file

@ -10,6 +10,18 @@ describe PeopleHelper, :type => :helper do
@person = FactoryGirl.create(:person) @person = FactoryGirl.create(:person)
end end
describe "#birthday_format" do
it "contains the birth year if available" do
birthday = Date.new 2016, 3, 5
expect(birthday_format(birthday)).to include "2016"
end
it "does not contain the birth year if placeholder year is used" do
birthday = Date.new 1004, 3, 5
expect(birthday_format(birthday)).not_to include "1004"
end
end
describe "#person_image_link" do describe "#person_image_link" do
it "returns an empty string if person is nil" do it "returns an empty string if person is nil" do
expect(person_image_link(nil)).to eq("") expect(person_image_link(nil)).to eq("")