parent
1ad161ace3
commit
56e9843b3c
@ -0,0 +1,54 @@ |
||||
module Settings |
||||
## |
||||
# A text field to enter numeric values. |
||||
class TimeZoneSettingCell < ::RailsCell |
||||
include ActionView::Helpers::FormOptionsHelper |
||||
include SettingsHelper |
||||
|
||||
options :form, :title |
||||
options container_class: "-wide" |
||||
options include_blank: true |
||||
|
||||
def name # name of setting and tag |
||||
model |
||||
end |
||||
|
||||
def render_select |
||||
if form.nil? |
||||
render_setting_select |
||||
else |
||||
render_form_select |
||||
end |
||||
end |
||||
|
||||
def render_form_select |
||||
form.select( |
||||
name, |
||||
time_zone_entries, |
||||
include_blank: include_blank, |
||||
container_class: container_class, |
||||
title: title |
||||
) |
||||
end |
||||
|
||||
def render_setting_select |
||||
setting_select( |
||||
name, |
||||
time_zone_entries, |
||||
include_blank: include_blank, |
||||
container_class: container_class, |
||||
title: title |
||||
) |
||||
end |
||||
|
||||
def time_zones |
||||
ActiveSupport::TimeZone.all |
||||
end |
||||
|
||||
## |
||||
# Returns time zone (label, value) tuples to be used for a select field. |
||||
def time_zone_entries |
||||
time_zones.map { |tz| [tz.to_s, tz.name ] } |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,3 @@ |
||||
<div class="form--field"> |
||||
<%= render_select %> |
||||
</div> |
@ -0,0 +1,45 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require "spec_helper" |
||||
|
||||
describe User, "default time zone" do |
||||
let(:user) { FactoryGirl.create :user } |
||||
|
||||
context "with no system default set" do |
||||
it "is not set" do |
||||
expect(user.pref.time_zone).to be_nil |
||||
end |
||||
end |
||||
|
||||
context "with a system default set", with_settings: { user_default_timezone: "Edinburgh" } do |
||||
it "is set to the default" do |
||||
expect(user.pref.time_zone).to eq "Edinburgh" |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue