Merge pull request #3164 from NobodysNightmare/feature/private_mail_by_default

Hide Mail address by default
pull/3045/merge
Florian Kraft 9 years ago
commit 524dc0ec30
  1. 33
      db/migrate/20150623151337_hide_mail_by_default.rb
  2. 2
      spec/factories/user_preference_factory.rb
  3. 8
      spec/lib/api/v3/users/user_representer_spec.rb
  4. 47
      spec/models/user_preference_spec.rb

@ -0,0 +1,33 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 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-2013 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 doc/COPYRIGHT.rdoc for more details.
#++
class HideMailByDefault < ActiveRecord::Migration
def change
change_column_default :user_preferences, :hide_mail, true
end
end

@ -29,7 +29,7 @@
FactoryGirl.define do FactoryGirl.define do
factory :user_preference do factory :user_preference do
user user
hide_mail 0 hide_mail true
others = {} others = {}
end end
end end

@ -45,12 +45,8 @@ describe ::API::V3::Users::UserRepresenter do
it { is_expected.to have_json_path('name') } it { is_expected.to have_json_path('name') }
describe 'email' do describe 'email' do
it 'shows the users E-Mail address' do
is_expected.to be_json_eql(user.mail.to_json).at_path('email')
end
context 'user shows his E-Mail address' do context 'user shows his E-Mail address' do
let(:preference) { FactoryGirl.build(:user_preference, hide_mail: 0) } let(:preference) { FactoryGirl.build(:user_preference, hide_mail: false) }
let(:user) { FactoryGirl.build_stubbed(:user, status: 1, preference: preference) } let(:user) { FactoryGirl.build_stubbed(:user, status: 1, preference: preference) }
it 'shows the users E-Mail address' do it 'shows the users E-Mail address' do
@ -59,7 +55,7 @@ describe ::API::V3::Users::UserRepresenter do
end end
context 'user hides his E-Mail address' do context 'user hides his E-Mail address' do
let(:preference) { FactoryGirl.build(:user_preference, hide_mail: 1) } let(:preference) { FactoryGirl.build(:user_preference, hide_mail: true) }
let(:user) { FactoryGirl.build_stubbed(:user, status: 1, preference: preference) } let(:user) { FactoryGirl.build_stubbed(:user, status: 1, preference: preference) }
it 'hides the users E-Mail address' do it 'hides the users E-Mail address' do

@ -0,0 +1,47 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 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-2013 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 doc/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe UserPreference do
subject { described_class.new }
describe 'default settings' do
it 'hides the email address' do
expect(subject.hide_mail).to eql(true)
end
it 'has an empty others hash' do
expect(subject.others).to eql({})
end
it 'disables accessibility mode' do
expect(subject.impaired).to eql(false)
end
end
end
Loading…
Cancel
Save