1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-21 15:54:22 +01:00

move gender & birthday to statistic_profile

This commit is contained in:
Sylvain 2019-06-04 13:33:00 +02:00
parent 42e73e4315
commit 52992ac9d5
43 changed files with 474 additions and 336 deletions

View File

@ -264,8 +264,8 @@ Application.Controllers.controller('AdminCalendarController', ['$scope', '$state
* @return {string} 'male' or 'female' * @return {string} 'male' or 'female'
*/ */
var getGender = function (user) { var getGender = function (user) {
if (user.profile) { if (user.statistic_profile) {
if (user.profile.gender === 'true') { return 'male'; } else { return 'female'; } if (user.statistic_profile.gender === 'true') { return 'male'; } else { return 'female'; }
} else { return 'other'; } } else { return 'other'; }
}; };

View File

@ -536,7 +536,7 @@ Application.Controllers.controller('EditMemberController', ['$scope', '$state',
CSRF.setMetaTags(); CSRF.setMetaTags();
// init the birth date to JS object // init the birth date to JS object
$scope.user.profile.birthday = moment($scope.user.profile.birthday).toDate(); $scope.user.statistic_profile.birthday = moment($scope.user.statistic_profile.birthday).toDate();
// the user subscription // the user subscription
if (($scope.user.subscribed_plan != null) && ($scope.user.subscription != null)) { if (($scope.user.subscribed_plan != null) && ($scope.user.subscription != null)) {
@ -604,9 +604,10 @@ Application.Controllers.controller('NewAdminController', ['$state', '$scope', 'A
// default admin profile // default admin profile
let getGender; let getGender;
$scope.admin = { $scope.admin = {
profile_attributes: { statistic_profile_attributes: {
gender: true gender: true
}, },
profile_attributes: {},
invoicing_profile_attributes: {} invoicing_profile_attributes: {}
}; };
@ -650,8 +651,8 @@ Application.Controllers.controller('NewAdminController', ['$state', '$scope', 'A
* @return {string} 'male' or 'female' * @return {string} 'male' or 'female'
*/ */
return getGender = function (user) { return getGender = function (user) {
if (user.profile_attributes) { if (user.statistic_profile_attributes) {
if (user.profile_attributes.gender) { return 'male'; } else { return 'female'; } if (user.statistic_profile_attributes.gender) { return 'male'; } else { return 'female'; }
} else { return 'other'; } } else { return 'other'; }
}; };
} }

View File

@ -86,7 +86,7 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
return $uibModal.open({ return $uibModal.open({
templateUrl: '<%= asset_path "shared/signupModal.html" %>', templateUrl: '<%= asset_path "shared/signupModal.html" %>',
size: 'md', size: 'md',
controller: ['$scope', '$uibModalInstance', 'Group', 'CustomAsset', function ($scope, $uibModalInstance, Group, CustomAsset) { controller: ['$scope', '$uibModalInstance', 'Group', 'CustomAsset', 'growl', '_t', function ($scope, $uibModalInstance, Group, CustomAsset, growl, _t) {
// default parameters for the date picker in the account creation modal // default parameters for the date picker in the account creation modal
$scope.datePicker = { $scope.datePicker = {
format: Fablab.uibDateFormat, format: Fablab.uibDateFormat,
@ -134,8 +134,13 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
delete $scope.user.organization; delete $scope.user.organization;
// register on server // register on server
return Auth.register($scope.user).then(function (user) { return Auth.register($scope.user).then(function (user) {
// creation successful if (user.id) {
$uibModalInstance.close(user); // creation successful
$uibModalInstance.close(user);
} else {
// the user was not saved in database, something wrong occurred
growl.error(_t('unexpected_error_occurred'));
}
}, function (error) { }, function (error) {
// creation failed... // creation failed...
// restore organization param // restore organization param

View File

@ -258,7 +258,7 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco
CSRF.setMetaTags(); CSRF.setMetaTags();
// init the birth date to JS object // init the birth date to JS object
$scope.user.profile.birthday = moment($scope.user.profile.birthday).toDate(); $scope.user.statistic_profile.birthday = moment($scope.user.statistic_profile.birthday).toDate();
if ($scope.activeProvider.providable_type !== 'DatabaseProvider') { if ($scope.activeProvider.providable_type !== 'DatabaseProvider') {
$scope.preventPassword = true; $scope.preventPassword = true;

View File

@ -150,8 +150,8 @@ Application.Controllers.controller('PlansIndexController', ['$scope', '$rootScop
* @return {string} 'male' or 'female' * @return {string} 'male' or 'female'
*/ */
$scope.getGender = function (user) { $scope.getGender = function (user) {
if (user && user.profile) { if (user && user.statistic_profile) {
if (user.profile.gender === 'true') { return 'male'; } else { return 'female'; } if (user.statistic_profile.gender === 'true') { return 'male'; } else { return 'female'; }
} else { return 'other'; } } else { return 'other'; }
}; };

View File

@ -206,7 +206,7 @@ Application.Controllers.controller('CompleteProfileController', ['$scope', '$roo
CSRF.setMetaTags(); CSRF.setMetaTags();
// init the birth date to JS object // init the birth date to JS object
$scope.user.profile.birthday = moment($scope.user.profile.birthday).toDate(); $scope.user.statistic_profile.birthday = moment($scope.user.statistic_profile.birthday).toDate();
// bind fields protection with sso fields // bind fields protection with sso fields
angular.forEach(activeProviderPromise.mapping, function (map) { $scope.preventField[map] = true; }); angular.forEach(activeProviderPromise.mapping, function (map) { $scope.preventField[map] = true; });

View File

@ -1,18 +1,18 @@
<div class="row m-t"> <div class="row m-t">
<div class="col-sm-offset-3 col-sm-6"> <div class="col-sm-offset-3 col-sm-6">
<div class="form-group" ng-class="{'has-error': adminForm['admin[profile_attributes][gender]'].$dirty && adminForm['admin[profile_attributes][gender]'].$invalid}"> <div class="form-group" ng-class="{'has-error': adminForm['admin[statistic_profile_attributes][gender]'].$dirty && adminForm['admin[statistic_profile_attributes][gender]'].$invalid}">
<label class="checkbox-inline btn btn-default"> <label class="checkbox-inline btn btn-default">
<input type="radio" <input type="radio"
name="admin[profile_attributes][gender]" name="admin[statistic_profile_attributes][gender]"
ng-model="admin.profile_attributes.gender" ng-model="admin.statistic_profile_attributes.gender"
ng-value="true" ng-value="true"
required/> required/>
<i class="fa fa-male m-l-sm"></i> {{ 'man' | translate }} <i class="fa fa-male m-l-sm"></i> {{ 'man' | translate }}
</label> </label>
<label class="checkbox-inline btn btn-default"> <label class="checkbox-inline btn btn-default">
<input type="radio" <input type="radio"
name="admin[profile_attributes][gender]" name="admin[statistic_profile_attributes][gender]"
ng-model="admin.profile_attributes.gender" ng-model="admin.statistic_profile_attributes.gender"
ng-value="false"/> ng-value="false"/>
<i class="fa fa-female m-l-sm"></i> {{ 'woman' | translate }} <i class="fa fa-female m-l-sm"></i> {{ 'woman' | translate }}
</label> </label>
@ -73,13 +73,13 @@
<span class="help-block" ng-show="adminForm['admin[email]'].$dirty && adminForm['admin[email]'].$error.required" translate>{{ 'email_is_required' }}</span> <span class="help-block" ng-show="adminForm['admin[email]'].$dirty && adminForm['admin[email]'].$error.required" translate>{{ 'email_is_required' }}</span>
</div> </div>
<div class="form-group" ng-class="{'has-error': adminForm['admin[profile_attributes][birthday]'].$dirty && adminForm['admin[profile_attributes][birthday]'].$invalid}"> <div class="form-group" ng-class="{'has-error': adminForm['admin[statistic_profile_attributes][birthday]'].$dirty && adminForm['admin[statistic_profile_attributes][birthday]'].$invalid}">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar-o"></i> </span> <span class="input-group-addon"><i class="fa fa-calendar-o"></i> </span>
<input type="text" <input type="text"
id="user_birthday" id="user_birthday"
class="form-control" class="form-control"
ng-model="admin.profile_attributes.birthday" ng-model="admin.statistic_profile_attributes.birthday"
uib-datepicker-popup="{{datePicker.format}}" uib-datepicker-popup="{{datePicker.format}}"
datepicker-options="datePicker.options" datepicker-options="datePicker.options"
is-open="datePicker.opened" is-open="datePicker.opened"
@ -87,8 +87,8 @@
ng-click="openDatePicker($event)" ng-click="openDatePicker($event)"
/> />
<input type="hidden" <input type="hidden"
name="admin[profile_attributes][birthday]" name="admin[statistic_profile_attributes][birthday]"
value="{{admin.profile_attributes.birthday | toIsoDate}}" /> value="{{admin.statistic_profile_attributes.birthday | toIsoDate}}" />
</div> </div>
</div> </div>

View File

@ -38,27 +38,27 @@
</div> </div>
<div class="col-sm-offset-1 col-sm-6"> <div class="col-sm-offset-1 col-sm-6">
<div class="form-group" ng-class="{'has-error': userForm['user[profile_attributes][gender]'].$dirty && userForm['user[profile_attributes][gender]'].$invalid}"> <div class="form-group" ng-class="{'has-error': userForm['user[statistic_profile_attributes][gender]'].$dirty && userForm['user[statistic_profile_attributes][gender]'].$invalid}">
<label class="checkbox-inline btn btn-default"> <label class="checkbox-inline btn btn-default">
<input type="radio" <input type="radio"
name="user[profile_attributes][gender]" name="user[statistic_profile_attributes][gender]"
ng-model="user.profile.gender" ng-model="user.statistic_profile.gender"
value="true" value="true"
ng-disabled="preventField['profile.gender'] && user.profile.gender && !userForm['user[profile_attributes][gender]'].$dirty" ng-disabled="preventField['profile.gender'] && user.profile.gender && !userForm['user[statistic_profile_attributes][gender]'].$dirty"
required/> required/>
<i class="fa fa-male m-l-sm"></i> {{ 'man' | translate }} <i class="fa fa-male m-l-sm"></i> {{ 'man' | translate }}
</label> </label>
<label class="checkbox-inline btn btn-default"> <label class="checkbox-inline btn btn-default">
<input type="radio" <input type="radio"
name="user[profile_attributes][gender]" name="user[statistic_profile_attributes][gender]"
ng-model="user.profile.gender" ng-model="user.statistic_profile.gender"
value="false" value="false"
ng-disabled="preventField['profile.gender'] && user.profile.gender && !userForm['user[profile_attributes][gender]'].$dirty"/> ng-disabled="preventField['profile.gender'] && user.profile.gender && !userForm['user[statistic_profile_attributes][gender]'].$dirty"/>
<i class="fa fa-female m-l-sm"></i> {{ 'woman' | translate }} <i class="fa fa-female m-l-sm"></i> {{ 'woman' | translate }}
</label> </label>
<span class="exponent m-l-xs"><i class="fa fa-asterisk" aria-hidden="true"></i></span> <span class="exponent m-l-xs"><i class="fa fa-asterisk" aria-hidden="true"></i></span>
<span class="help-block" ng-show="userForm['user[profile_attributes][gender]'].$dirty && userForm['user[profile_attributes][gender]'].$error.required" translate>{{ 'gender_is_required' }}</span> <span class="help-block" ng-show="userForm['user[statistic_profile_attributes][gender]'].$dirty && userForm['user[statistic_profile_attributes][gender]'].$error.required" translate>{{ 'gender_is_required' }}</span>
</div> </div>
@ -200,25 +200,25 @@
<span class="help-block" ng-show="userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$error.required" translate>{{ 'organization_address_is_required' }}</span> <span class="help-block" ng-show="userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$error.required" translate>{{ 'organization_address_is_required' }}</span>
</div> </div>
<div class="form-group" ng-class="{'has-error': userForm['user[profile_attributes][birthday]'].$dirty && userForm['user[profile_attributes][birthday]'].$invalid}"> <div class="form-group" ng-class="{'has-error': userForm['user[statistic_profile_attributes][birthday]'].$dirty && userForm['user[statistic_profile_attributes][birthday]'].$invalid}">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar-o"></i> <span class="exponent"><i class="fa fa-asterisk" aria-hidden="true"></i></span></span> <span class="input-group-addon"><i class="fa fa-calendar-o"></i> <span class="exponent"><i class="fa fa-asterisk" aria-hidden="true"></i></span></span>
<input type="text" <input type="text"
id="user_birthday" id="user_birthday"
class="form-control" class="form-control"
ng-model="user.profile.birthday" ng-model="user.statistic_profile.birthday"
uib-datepicker-popup="{{datePicker.format}}" uib-datepicker-popup="{{datePicker.format}}"
datepicker-options="datePicker.options" datepicker-options="datePicker.options"
is-open="datePicker.opened" is-open="datePicker.opened"
placeholder="{{ 'date_of_birth' | translate }}" placeholder="{{ 'date_of_birth' | translate }}"
ng-click="openDatePicker($event)" ng-click="openDatePicker($event)"
ng-disabled="preventField['profile.birthday'] && user.profile.birthday && !userForm['user[profile_attributes][birthday]'].$dirty" ng-disabled="preventField['profile.birthday'] && user.statistic_profile.birthday && !userForm['user[statistic_profile_attributes][birthday]'].$dirty"
required/> required/>
<input type="hidden" <input type="hidden"
name="user[profile_attributes][birthday]" name="user[statistic_profile_attributes][birthday]"
value="{{user.profile.birthday | toIsoDate}}" /> value="{{user.statistic_profile.birthday | toIsoDate}}" />
</div> </div>
<span class="help-block" ng-show="userForm['user[profile_attributes][birthday]'].$dirty && userForm['user[profile_attributes][birthday]'].$error.required" translate>{{ 'date_of_birth_is_required' }}</span> <span class="help-block" ng-show="userForm['user[statistic_profile_attributes][birthday]'].$dirty && userForm['user[statistic_profile_attributes][birthday]'].$error.required" translate>{{ 'date_of_birth_is_required' }}</span>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -12,14 +12,14 @@
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="radio" <input type="radio"
name="gender" name="gender"
ng-model="user.profile_attributes.gender" ng-model="user.statistic_profile_attributes.gender"
value="true" value="true"
required/> {{ 'man' | translate }} required/> {{ 'man' | translate }}
</label> </label>
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="radio" <input type="radio"
name="gender" name="gender"
ng-model="user.profile_attributes.gender" ng-model="user.statistic_profile_attributes.gender"
value="false"/> {{ 'woman' | translate }} value="false"/> {{ 'woman' | translate }}
</label> </label>
<span class="exponent m-l-xs"><i class="fa fa-asterisk" aria-hidden="true"></i></span> <span class="exponent m-l-xs"><i class="fa fa-asterisk" aria-hidden="true"></i></span>
@ -182,7 +182,7 @@
<input type="text" <input type="text"
class="form-control" class="form-control"
name="birthday" name="birthday"
ng-model="user.profile_attributes.birthday" ng-model="user.statistic_profile_attributes.birthday"
uib-datepicker-popup="{{datePicker.format}}" uib-datepicker-popup="{{datePicker.format}}"
datepicker-options="datePicker.options" datepicker-options="datePicker.options"
is-open="datePicker.opened" is-open="datePicker.opened"

View File

@ -11,24 +11,13 @@ class API::AdminsController < API::ApiController
def create def create
authorize :admin authorize :admin
generated_password = Devise.friendly_token.first(8) res = UserService.create_admin(admin_params)
@admin = User.new(admin_params.merge(password: generated_password))
@admin.send :set_slug
# we associate the admin group to prevent linking any other 'normal' group (which won't be deletable afterwards) if res[:saved]
@admin.group = Group.find_by(slug: 'admins') @admin = res[:user]
# if the authentication is made through an SSO, generate a migration token
@admin.generate_auth_migration_token unless AuthProvider.active.providable_type == DatabaseProvider.name
if @admin.save(validate: false)
@admin.send_confirmation_instructions
@admin.add_role(:admin)
@admin.remove_role(:member)
UsersMailer.delay.notify_user_account_created(@admin, generated_password)
render :create, status: :created render :create, status: :created
else else
render json: @admin.errors.full_messages, status: :unprocessable_entity render json: res[:user].errors.full_messages, status: :unprocessable_entity
end end
end end
@ -47,8 +36,9 @@ class API::AdminsController < API::ApiController
def admin_params def admin_params
params.require(:admin).permit( params.require(:admin).permit(
:username, :email, :username, :email,
profile_attributes: %i[first_name last_name gender birthday phone], profile_attributes: %i[first_name last_name phone],
invoicing_profile_attributes: [address_attributes: [:address]] invoicing_profile_attributes: [address_attributes: [:address]],
statistic_profile_attributes: %i[gender birthday]
) )
end end
end end

View File

@ -191,30 +191,30 @@ class API::MembersController < API::ApiController
if current_user.id == params[:id].to_i if current_user.id == params[:id].to_i
params.require(:user).permit(:username, :email, :password, :password_confirmation, :group_id, :is_allow_contact, params.require(:user).permit(:username, :email, :password, :password_confirmation, :group_id, :is_allow_contact,
:is_allow_newsletter, :is_allow_newsletter,
profile_attributes: [:id, :first_name, :last_name, :gender, :birthday, :phone, :interest, profile_attributes: [:id, :first_name, :last_name, :phone, :interest, :software_mastered, :website, :job,
:software_mastered, :website, :job, :facebook, :twitter, :facebook, :twitter, :google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo,
:google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo,
:dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr,
user_avatar_attributes: %i[id attachment destroy]], user_avatar_attributes: %i[id attachment destroy]],
invoicing_profile_attributes: [ invoicing_profile_attributes: [
address_attributes: %i[id address], address_attributes: %i[id address],
organization_attributes: [:id, :name, address_attributes: %i[id address]] organization_attributes: [:id, :name, address_attributes: %i[id address]]
]) ],
statistic_profile_attributes: %i[id gender birthday])
elsif current_user.admin? elsif current_user.admin?
params.require(:user).permit(:username, :email, :password, :password_confirmation, params.require(:user).permit(:username, :email, :password, :password_confirmation,
:is_allow_contact, :is_allow_newsletter, :group_id, :is_allow_contact, :is_allow_newsletter, :group_id,
training_ids: [], tag_ids: [], training_ids: [], tag_ids: [],
profile_attributes: [:id, :first_name, :last_name, :gender, :birthday, :phone, :interest, profile_attributes: [:id, :first_name, :last_name, :phone, :interest, :software_mastered, :website, :job,
:software_mastered, :website, :job, :facebook, :twitter, :facebook, :twitter, :google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo,
:google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo,
:dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr,
user_avatar_attributes: %i[id attachment destroy]], user_avatar_attributes: %i[id attachment destroy]],
invoicing_profile_attributes: [ invoicing_profile_attributes: [
:id, :id,
address_attributes: %i[id address], address_attributes: %i[id address],
organization_attributes: [:id, :name, address_attributes: %i[id address]] organization_attributes: [:id, :name, address_attributes: %i[id address]]
]) ],
statistic_profile_attributes: %i[id gender birthday])
end end
end end

View File

@ -14,24 +14,13 @@ class API::UsersController < API::ApiController
def create def create
if current_user.admin? if current_user.admin?
generated_password = Devise.friendly_token.first(8) res = UserService.create_partner(partner_params)
@user = User.new(email: partner_params[:email],
username: "#{partner_params[:first_name]}#{partner_params[:last_name]}",
password: generated_password,
password_confirmation: generated_password,
group_id: Group.first.id)
@user.build_profile(first_name: partner_params[:first_name],
last_name: partner_params[:last_name],
gender: true,
birthday: Time.now,
phone: '0000000000')
if @user.save if res[:saved]
@user.remove_role :member @user = res[:user]
@user.add_role :partner
render status: :created render status: :created
else else
render json: @user.errors.full_messages, status: :unprocessable_entity render json: res[:user].errors.full_messages, status: :unprocessable_entity
end end
else else
head 403 head 403

View File

@ -33,10 +33,11 @@ class ApplicationController < ActionController::Base
devise_parameter_sanitizer.permit(:sign_up, devise_parameter_sanitizer.permit(:sign_up,
keys: [ keys: [
{ {
profile_attributes: %i[phone last_name first_name gender birthday interest software_mastered], profile_attributes: %i[phone last_name first_name interest software_mastered],
invoicing_profile_attributes: [ invoicing_profile_attributes: [
organization_attributes: [:name, address_attributes: [:address]] organization_attributes: [:name, address_attributes: [:address]]
] ],
statistic_profile_attributes: %i[gender birthday]
}, },
:username, :is_allow_contact, :is_allow_newsletter, :cgu, :group_id :username, :is_allow_contact, :is_allow_newsletter, :cgu, :group_id
]) ])

View File

@ -1,5 +1,8 @@
# frozen_string_literal: true
# Handling a new user registration through the sign-up modal
class RegistrationsController < Devise::RegistrationsController class RegistrationsController < Devise::RegistrationsController
# POST /resource # POST /users.json
def create def create
build_resource(sign_up_params) build_resource(sign_up_params)
@ -24,5 +27,4 @@ class RegistrationsController < Devise::RegistrationsController
respond_with resource respond_with resource
end end
end end
end end

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Devise controller for handling client sessions
class SessionsController < Devise::SessionsController class SessionsController < Devise::SessionsController
#before_action :set_csrf_headers, only: [:create, :destroy]
def new def new
active_provider = AuthProvider.active active_provider = AuthProvider.active
@ -9,9 +11,4 @@ class SessionsController < Devise::SessionsController
super super
end end
end end
protected
def set_csrf_headers
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
end
end end

View File

@ -1,3 +1,8 @@
# frozen_string_literal: true
# This table will save the user's profile data needed for legal accounting (invoices, wallet, etc.)
# Legal accounting must be kept for 10 years but GDPR requires that an user can delete his account at any time.
# The data will be kept even if the user is deleted, but it will be unlinked from the user's account.
class InvoicingProfile < ActiveRecord::Base class InvoicingProfile < ActiveRecord::Base
belongs_to :user belongs_to :user
has_one :address, as: :placeable, dependent: :destroy has_one :address, as: :placeable, dependent: :destroy

View File

@ -10,12 +10,9 @@ class Profile < ActiveRecord::Base
validates :first_name, presence: true, length: { maximum: 30 } validates :first_name, presence: true, length: { maximum: 30 }
validates :last_name, presence: true, length: { maximum: 30 } validates :last_name, presence: true, length: { maximum: 30 }
validates :gender, inclusion: { in: [true, false] }
validates :birthday, presence: true
validates_numericality_of :phone, only_integer: true, allow_blank: false validates_numericality_of :phone, only_integer: true, allow_blank: false
after_save :update_invoicing_profile, if: invoicing_data_was_modified? after_save :update_invoicing_profile, if: :invoicing_data_was_modified?
after_save :update_statistic_profile, if: statistic_data_was_modified?
def full_name def full_name
# if first_name or last_name is nil, the empty string will be used as a temporary replacement # if first_name or last_name is nil, the empty string will be used as a temporary replacement
@ -26,19 +23,6 @@ class Profile < ActiveRecord::Base
full_name full_name
end end
def age
if birthday.present?
now = Time.now.utc.to_date
(now - birthday).to_f / 365.2425
else
''
end
end
def str_gender
gender ? 'male' : 'female'
end
def self.mapping def self.mapping
# we protect some fields as they are designed to be managed by the system and must not be updated externally # we protect some fields as they are designed to be managed by the system and must not be updated externally
blacklist = %w[id user_id created_at updated_at] blacklist = %w[id user_id created_at updated_at]
@ -56,10 +40,6 @@ class Profile < ActiveRecord::Base
first_name_changed? or last_name_changed? or new_record? first_name_changed? or last_name_changed? or new_record?
end end
def statistic_data_was_modified?
birthday_changed? or gender_changed? or new_record?
end
def update_invoicing_profile def update_invoicing_profile
if user.invoicing_profile.nil? if user.invoicing_profile.nil?
InvoicingProfile.create!( InvoicingProfile.create!(
@ -75,19 +55,4 @@ class Profile < ActiveRecord::Base
end end
end end
def update_statistic_profile
if statistic_profile.nil?
StatisticProfile.create!(
user: user,
birthday: birthday,
gender: gender
)
else
statistic_profile.update_attributes(
birthday: birthday,
gender: gender
)
end
end
end end

View File

@ -1,6 +1,25 @@
# frozen_string_literal: true
# This table will save the user's profile data needed for statistical purposes.
# GDPR requires that an user can delete his account at any time but we need to keep the statistics original data to being able to
# rebuild them at any time.
# The data will be kept even if the user is deleted, but it will be unlinked from the user's account (ie. anonymized)
class StatisticProfile < ActiveRecord::Base class StatisticProfile < ActiveRecord::Base
belongs_to :user belongs_to :user
belongs_to :group belongs_to :group
# relations to reservations, trainings, subscriptions # relations to reservations, trainings, subscriptions
def str_gender
gender ? 'male' : 'female'
end
def age
if birthday.present?
now = Time.now.utc.to_date
(now - birthday).to_f / 365.2425
else
''
end
end
end end

View File

@ -66,8 +66,8 @@ class User < ActiveRecord::Base
after_commit :create_stripe_customer, on: [:create] after_commit :create_stripe_customer, on: [:create]
after_commit :notify_admin_when_user_is_created, on: :create after_commit :notify_admin_when_user_is_created, on: :create
after_update :notify_group_changed, if: :group_id_changed? after_update :notify_group_changed, if: :group_id_changed?
after_save :update_invoicing_profile, if: invoicing_data_was_modified? after_save :update_invoicing_profile, if: :invoicing_data_was_modified?
after_save :update_statistic_profile, if: statistic_data_was_modified? after_save :update_statistic_profile, if: :statistic_data_was_modified?
attr_accessor :cgu attr_accessor :cgu
delegate :first_name, to: :profile delegate :first_name, to: :profile
@ -170,9 +170,7 @@ class User < ActiveRecord::Base
def self.from_omniauth(auth) def self.from_omniauth(auth)
active_provider = AuthProvider.active active_provider = AuthProvider.active
if active_provider.strategy_name != auth.provider raise SecurityError, 'The identity provider does not match the activated one' if active_provider.strategy_name != auth.provider
raise SecurityError, 'The identity provider does not match the activated one'
end
where(provider: auth.provider, uid: auth.uid).first_or_create.tap do |user| where(provider: auth.provider, uid: auth.uid).first_or_create.tap do |user|
# execute this regardless of whether record exists or not (-> User#tap) # execute this regardless of whether record exists or not (-> User#tap)
@ -186,8 +184,8 @@ class User < ActiveRecord::Base
end end
def need_completion? def need_completion?
profile.gender.nil? || profile.first_name.blank? || profile.last_name.blank? || username.blank? || statistic_profile.gender.nil? || profile.first_name.blank? || profile.last_name.blank? || username.blank? ||
email.blank? || encrypted_password.blank? || group_id.nil? || profile.birthday.blank? || profile.phone.blank? email.blank? || encrypted_password.blank? || group_id.nil? || statistic_profile.birthday.blank? || profile.phone.blank?
end end
## Retrieve the requested data in the User and user's Profile tables ## Retrieve the requested data in the User and user's Profile tables
@ -248,9 +246,7 @@ class User < ActiveRecord::Base
## and remove the auth_token to mark his account as "migrated" ## and remove the auth_token to mark his account as "migrated"
def link_with_omniauth_provider(auth) def link_with_omniauth_provider(auth)
active_provider = AuthProvider.active active_provider = AuthProvider.active
if active_provider.strategy_name != auth.provider raise SecurityError, 'The identity provider does not match the activated one' if active_provider.strategy_name != auth.provider
raise SecurityError, 'The identity provider does not match the activated one'
end
if User.where(provider: auth.provider, uid: auth.uid).size.positive? if User.where(provider: auth.provider, uid: auth.uid).size.positive?
raise DuplicateIndexError, "This #{active_provider.name} account is already linked to an existing user" raise DuplicateIndexError, "This #{active_provider.name} account is already linked to an existing user"
@ -374,7 +370,6 @@ class User < ActiveRecord::Base
group_id_changed? or new_record? group_id_changed? or new_record?
end end
def update_invoicing_profile def update_invoicing_profile
if invoicing_profile.nil? if invoicing_profile.nil?
InvoicingProfile.create!( InvoicingProfile.create!(

View File

@ -356,8 +356,8 @@ class StatisticService
def user_info(user) def user_info(user)
{ {
user_id: user.id, user_id: user.id,
gender: user.profile.str_gender, gender: user.statistic_profile.str_gender,
age: user.profile.age, age: user.statistic_profile.age,
group: user.group ? user.group.slug : nil, group: user.group ? user.group.slug : nil,
email: user.email email: user.email
} }

View File

@ -0,0 +1,53 @@
# frozen_string_literal: true
# helpers for managing users with special roles
class UserService
def self.create_partner(params)
generated_password = Devise.friendly_token.first(8)
group_id = Group.first.id
user = User.new(
email: params[:email],
username: "#{params[:first_name]}#{params[:last_name]}".parameterize,
password: generated_password,
password_confirmation: generated_password,
group_id: group_id
)
user.build_profile(
first_name: params[:first_name],
last_name: params[:last_name],
phone: '0000000000'
)
user.build_statistic_profile(
gender: true,
birthday: Time.now
)
saved = user.save
if saved
user.remove_role :member
user.add_role :partner
end
{ saved: saved, user: user }
end
def self.create_admin(params)
generated_password = Devise.friendly_token.first(8)
admin = User.new(params.merge(password: generated_password))
admin.send :set_slug
# we associate the admin group to prevent linking any other 'normal' group (which won't be deletable afterwards)
admin.group = Group.find_by(slug: 'admins')
# if the authentication is made through an SSO, generate a migration token
admin.generate_auth_migration_token unless AuthProvider.active.providable_type == DatabaseProvider.name
saved = admin.save(validate: false)
if saved
admin.send_confirmation_instructions
admin.add_role(:admin)
admin.remove_role(:member)
UsersMailer.delay.notify_user_account_created(admin, generated_password)
end
{ saved: saved, user: admin }
end
end

View File

@ -3,8 +3,8 @@ json.profile_attributes do
json.id admin.profile.id json.id admin.profile.id
json.first_name admin.profile.first_name json.first_name admin.profile.first_name
json.last_name admin.profile.last_name json.last_name admin.profile.last_name
json.gender admin.profile.gender json.gender admin.statistic_profile.gender
json.birthday admin.profile.birthday if admin.profile.birthday json.birthday admin.statistic_profile.birthday if admin.statistic_profile.birthday
json.phone admin.profile.phone json.phone admin.profile.phone
if admin.profile.user_avatar if admin.profile.user_avatar
json.user_avatar do json.user_avatar do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
json.extract! member, :id, :username, :email, :group_id json.extract! member, :id, :username, :email, :group_id
json.role member.roles.first.name json.role member.roles.first.name
json.name member.profile.full_name json.name member.profile.full_name
@ -13,8 +15,6 @@ json.profile do
end end
json.first_name member.profile.first_name json.first_name member.profile.first_name
json.last_name member.profile.last_name json.last_name member.profile.last_name
json.gender member.profile.gender.to_s
json.birthday member.profile.birthday.to_date.iso8601 if member.profile.birthday
json.interest member.profile.interest json.interest member.profile.interest
json.software_mastered member.profile.software_mastered json.software_mastered member.profile.software_mastered
json.phone member.profile.phone json.phone member.profile.phone
@ -46,6 +46,11 @@ json.invoicing_profile do
end end
end end
json.statistic_profile do
json.gender member.statistic_profile.gender.to_s
json.birthday member.statistic_profile&.birthday&.to_date&.iso8601
end
if member.subscribed_plan if member.subscribed_plan
json.subscribed_plan do json.subscribed_plan do
json.partial! 'api/shared/plan', plan: member.subscribed_plan json.partial! 'api/shared/plan', plan: member.subscribed_plan

View File

@ -1,4 +1,6 @@
user_is_admin = (current_user and current_user.admin?) # frozen_string_literal: true
user_is_admin = current_user&.admin?
max_members = @query.except(:offset, :limit, :order).count max_members = @query.except(:offset, :limit, :order).count
json.array!(@members) do |member| json.array!(@members) do |member|
@ -10,55 +12,77 @@ json.array!(@members) do |member|
json.email member.email if current_user json.email member.email if current_user
json.first_name member.profile.first_name json.first_name member.profile.first_name
json.last_name member.profile.last_name json.last_name member.profile.last_name
json.profile do
json.user_avatar do
json.id member.profile.user_avatar.id
json.attachment_url member.profile.user_avatar.attachment_url
end if member.profile.user_avatar
json.first_name member.profile.first_name
json.last_name member.profile.last_name
json.gender member.profile.gender.to_s
if user_is_admin
json.phone member.profile.phone
json.birthday member.profile.birthday.iso8601 if member.profile.birthday
end
end if attribute_requested?(@requested_attributes, 'profile')
json.need_completion member.need_completion? json.need_completion member.need_completion?
json.group_id member.group_id json.group_id member.group_id
json.group do
json.id member.group.id
json.name member.group.name
end if attribute_requested?(@requested_attributes, 'group') and member.group
if user_is_admin if attribute_requested?(@requested_attributes, 'profile')
json.subscribed_plan do json.profile do
json.partial! 'api/shared/plan', plan: member.subscribed_plan if member.profile.user_avatar
end if member.subscribed_plan json.user_avatar do
json.subscription do json.id member.profile.user_avatar.id
json.id member.subscription.id json.attachment_url member.profile.user_avatar.attachment_url
json.expired_at member.subscription.expired_at.iso8601 end
json.canceled_at member.subscription.canceled_at.iso8601 if member.subscription.canceled_at
json.stripe member.subscription.stp_subscription_id.present?
json.plan do
json.id member.subscription.plan.id
json.name member.subscription.plan.name
json.interval member.subscription.plan.interval
json.amount member.subscription.plan.amount ? (member.subscription.plan.amount / 100.0) : 0
end end
end if member.subscription json.first_name member.profile.first_name
end if attribute_requested?(@requested_attributes, 'subscription') json.last_name member.profile.last_name
json.gender member.statistic_profile.gender.to_s
end
if user_is_admin
json.statistic_profile do
json.phone member.statistic_profile.phone
json.birthday member.statistic_profile&.birthday&.iso8601
end
end
end
json.training_credits member.training_credits do |tc| if attribute_requested?(@requested_attributes, 'group') && member.group
json.training_id tc.creditable_id json.group do
end if attribute_requested?(@requested_attributes, 'credits') or attribute_requested?(@requested_attributes, 'training_credits') json.id member.group.id
json.name member.group.name
end
end
json.machine_credits member.machine_credits do |mc| if attribute_requested?(@requested_attributes, 'subscription')
json.machine_id mc.creditable_id if user_is_admin
json.hours_used mc.users_credits.find_by(user_id: member.id).hours_used if member.subscribed_plan
end if attribute_requested?(@requested_attributes, 'credits') or attribute_requested?(@requested_attributes, 'machine_credits') json.subscribed_plan do
json.partial! 'api/shared/plan', plan: member.subscribed_plan
end
end
if member.subscription
json.subscription do
json.id member.subscription.id
json.expired_at member.subscription.expired_at.iso8601
json.canceled_at member.subscription&.canceled_at&.iso8601
json.stripe member.subscription.stp_subscription_id.present?
json.plan do
json.id member.subscription.plan.id
json.name member.subscription.plan.name
json.interval member.subscription.plan.interval
json.amount member.subscription.plan.amount ? (member.subscription.plan.amount / 100.0) : 0
end
end
end
end
end
json.tags member.tags do |t| if attribute_requested?(@requested_attributes, 'credits') || attribute_requested?(@requested_attributes, 'training_credits')
json.id t.id json.training_credits member.training_credits do |tc|
json.name t.name json.training_id tc.creditable_id
end if attribute_requested?(@requested_attributes, 'tags') end
end
if attribute_requested?(@requested_attributes, 'credits') || attribute_requested?(@requested_attributes, 'machine_credits')
json.machine_credits member.machine_credits do |mc|
json.machine_id mc.creditable_id
json.hours_used mc.users_credits.find_by(user_id: member.id).hours_used
end
end
if attribute_requested?(@requested_attributes, 'tags')
json.tags member.tags do |t|
json.id t.id
json.name t.name
end
end
end end

View File

@ -39,13 +39,15 @@ json.all_projects @member.all_projects do |project|
json.first_name pu.user.profile.first_name json.first_name pu.user.profile.first_name
json.last_name pu.user.profile.last_name json.last_name pu.user.profile.last_name
json.full_name pu.user.profile.full_name json.full_name pu.user.profile.full_name
json.user_avatar do if pu.user.profile.user_avatar
json.id pu.user.profile.user_avatar.id json.user_avatar do
json.attachment_url pu.user.profile.user_avatar.attachment_url json.id pu.user.profile.user_avatar.id
end if pu.user.profile.user_avatar json.attachment_url pu.user.profile.user_avatar.attachment_url
end
end
json.username pu.user.username json.username pu.user.username
json.is_valid pu.is_valid json.is_valid pu.is_valid
json.valid_token pu.valid_token if !pu.is_valid and @member == pu.user json.valid_token pu.valid_token if !pu.is_valid && @member == pu.user
end end
end end
end end

View File

@ -1,2 +1,4 @@
json.extract! @user, :id, :email, :first_name, :last_name # frozen_string_literal: true
json.name "#{@user.first_name} #{@user.last_name}"
json.extract! @user, :id, :email, :first_name, :last_name
json.name @user.profile.full_name

View File

@ -1,4 +1,4 @@
json.users @users do |user| json.users @users do |user|
json.extract! user, :id, :email, :first_name, :last_name json.extract! user, :id, :email, :first_name, :last_name
json.name "#{user.first_name} #{user.last_name}" json.name user.profile.full_name
end end

View File

@ -14,10 +14,14 @@ json.invoices do
end end
end end
json.user do json.user do
json.extract! invoice[:invoice].user, :id, :email, :created_at json.extract! invoice[:invoice].invoicing_profile, :user_id, :email, :first_name, :last_name
json.profile do json.address invoice[:invoice].invoicing_profile&.address&.address
json.extract! invoice[:invoice].user.profile, :id, :first_name, :last_name, :birthday, :phone json.invoicing_profile_id invoice[:invoice].invoicing_profile.id
json.gender invoice[:invoice].user.profile.gender ? 'male' : 'female' if invoice[:invoice].invoicing_profile.organization
json.organization do
json.extract! invoice[:invoice].invoicing_profile.organization, :name, :id
json.address invoice[:invoice].invoicing_profile.organization&.address&.address
end
end end
end end
json.invoice_items invoice[:invoice].invoice_items do |item| json.invoice_items invoice[:invoice].invoice_items do |item|

View File

@ -86,6 +86,7 @@ en:
i_ve_read_and_i_accept_: "I've read and I accept" i_ve_read_and_i_accept_: "I've read and I accept"
_the_fablab_policy: "the FabLab policy" _the_fablab_policy: "the FabLab policy"
field_required: "Field required" field_required: "Field required"
unexpected_error_occurred: "An unexpected error occurred. Please try again later."
# password modification modal # password modification modal
change_your_password: "Change your password" change_your_password: "Change your password"

View File

@ -84,7 +84,8 @@ es:
i_accept_to_receive_information_from_the_fablab: "Acepto recibir información del FabLab" i_accept_to_receive_information_from_the_fablab: "Acepto recibir información del FabLab"
i_ve_read_and_i_accept_: "He leido y acepto" i_ve_read_and_i_accept_: "He leido y acepto"
_the_fablab_policy: "la política de FabLab" _the_fablab_policy: "la política de FabLab"
field_required: "Field required" #translation_missing field_required: "Field required" # translation missing
unexpected_error_occurred: "An unexpected error occurred. Please try again later." # translation missing
# password modification modal # password modification modal
change_your_password: "Cambiar contraseña" change_your_password: "Cambiar contraseña"

View File

@ -86,6 +86,7 @@ fr:
i_ve_read_and_i_accept_: "J'ai lu et j'accepte" i_ve_read_and_i_accept_: "J'ai lu et j'accepte"
_the_fablab_policy: "la charte d'utilisation du Fab Lab" _the_fablab_policy: "la charte d'utilisation du Fab Lab"
field_required: "Champ requis" field_required: "Champ requis"
unexpected_error_occurred: "Une erreur inattendue s'est produite. Veuillez réessayer ultérieurement."
# fenêtre de changement de mot de passe # fenêtre de changement de mot de passe
change_your_password: "Modifier votre mot de passe" change_your_password: "Modifier votre mot de passe"

View File

@ -85,7 +85,8 @@ pt:
i_accept_to_receive_information_from_the_fablab: "Eu aceito receber informações do FabLab" i_accept_to_receive_information_from_the_fablab: "Eu aceito receber informações do FabLab"
i_ve_read_and_i_accept_: "Eu li e aceito" i_ve_read_and_i_accept_: "Eu li e aceito"
_the_fablab_policy: "a política do FabLab" _the_fablab_policy: "a política do FabLab"
field_required: "Field required" #translation_missing field_required: "Field required" # translation missing
unexpected_error_occurred: "An unexpected error occurred. Please try again later." # translation missing
# password modification modal # password modification modal
change_your_password: "Mudar sua senha" change_your_password: "Mudar sua senha"

View File

@ -7,12 +7,14 @@ Rails.application.routes.draw do
if AuthProvider.active.providable_type == DatabaseProvider.name if AuthProvider.active.providable_type == DatabaseProvider.name
# with local authentification we do not use omniAuth so we must differentiate the config # with local authentification we do not use omniAuth so we must differentiate the config
devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions', devise_for :users, controllers: {
confirmations: 'confirmations', passwords: 'passwords'} registrations: 'registrations', sessions: 'sessions', confirmations: 'confirmations', passwords: 'passwords'
}
else else
devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions', devise_for :users, controllers: {
confirmations: 'confirmations', passwords: 'passwords', registrations: 'registrations', sessions: 'sessions', confirmations: 'confirmations', passwords: 'passwords',
:omniauth_callbacks => 'users/omniauth_callbacks'} omniauth_callbacks: 'users/omniauth_callbacks'
}
end end

View File

@ -1,15 +0,0 @@
class FeedStatisticProfile < ActiveRecord::Migration
def change
User.all.each do |u|
p = u.profile
puts "WARNING: User #{u.id} has no profile" and next unless p
StatisticProfile.create!(
user: u,
group: u.group,
gender: p.gender,
birthday: p.birthday
)
end
end
end

View File

@ -0,0 +1,27 @@
class MigrateProfileToStatisticProfile < ActiveRecord::Migration
def up
User.all.each do |u|
p = u.profile
puts "WARNING: User #{u.id} has no profile" and next unless p
StatisticProfile.create!(
user: u,
group: u.group,
gender: p.gender,
birthday: p.birthday
)
end
end
def down
StatisticProfile.all.each do |sp|
p = sp.user.profile
puts "WARNING: User #{sp.user_id} has no profile" and next unless p
p.update_attributes(
gender: sp.gender,
birthday: sp.birthday
)
end
end
end

View File

@ -0,0 +1,6 @@
class RemoveGenderBirthdayFromProfile < ActiveRecord::Migration
def change
remove_column :profiles, :gender, :boolean
remove_column :profiles, :birthday, :date
end
end

View File

@ -11,12 +11,12 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20190603141109) do ActiveRecord::Schema.define(version: 20190604075717) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
enable_extension "pg_trgm"
enable_extension "unaccent" enable_extension "unaccent"
enable_extension "pg_trgm"
create_table "abuses", force: :cascade do |t| create_table "abuses", force: :cascade do |t|
t.integer "signaled_id" t.integer "signaled_id"
@ -44,14 +44,14 @@ ActiveRecord::Schema.define(version: 20190603141109) do
end end
create_table "addresses", force: :cascade do |t| create_table "addresses", force: :cascade do |t|
t.string "address", limit: 255 t.string "address"
t.string "street_number", limit: 255 t.string "street_number"
t.string "route", limit: 255 t.string "route"
t.string "locality", limit: 255 t.string "locality"
t.string "country", limit: 255 t.string "country"
t.string "postal_code", limit: 255 t.string "postal_code"
t.integer "placeable_id" t.integer "placeable_id"
t.string "placeable_type", limit: 255 t.string "placeable_type"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
@ -67,9 +67,9 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "assets", force: :cascade do |t| create_table "assets", force: :cascade do |t|
t.integer "viewable_id" t.integer "viewable_id"
t.string "viewable_type", limit: 255 t.string "viewable_type"
t.string "attachment", limit: 255 t.string "attachment"
t.string "type", limit: 255 t.string "type"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
@ -86,12 +86,12 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "availabilities", force: :cascade do |t| create_table "availabilities", force: :cascade do |t|
t.datetime "start_at" t.datetime "start_at"
t.datetime "end_at" t.datetime "end_at"
t.string "available_type", limit: 255 t.string "available_type"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "nb_total_places" t.integer "nb_total_places"
t.boolean "destroying", default: false t.boolean "destroying", default: false
t.boolean "lock", default: false t.boolean "lock", default: false
end end
create_table "availability_tags", force: :cascade do |t| create_table "availability_tags", force: :cascade do |t|
@ -105,7 +105,7 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "availability_tags", ["tag_id"], name: "index_availability_tags_on_tag_id", using: :btree add_index "availability_tags", ["tag_id"], name: "index_availability_tags_on_tag_id", using: :btree
create_table "categories", force: :cascade do |t| create_table "categories", force: :cascade do |t|
t.string "name", limit: 255 t.string "name"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "slug" t.string "slug"
@ -114,7 +114,7 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "categories", ["slug"], name: "index_categories_on_slug", unique: true, using: :btree add_index "categories", ["slug"], name: "index_categories_on_slug", unique: true, using: :btree
create_table "components", force: :cascade do |t| create_table "components", force: :cascade do |t|
t.string "name", limit: 255, null: false t.string "name", null: false
end end
create_table "coupons", force: :cascade do |t| create_table "coupons", force: :cascade do |t|
@ -132,7 +132,7 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "credits", force: :cascade do |t| create_table "credits", force: :cascade do |t|
t.integer "creditable_id" t.integer "creditable_id"
t.string "creditable_type", limit: 255 t.string "creditable_type"
t.integer "plan_id" t.integer "plan_id"
t.integer "hours" t.integer "hours"
t.datetime "created_at" t.datetime "created_at"
@ -173,7 +173,7 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "event_themes", ["slug"], name: "index_event_themes_on_slug", unique: true, using: :btree add_index "event_themes", ["slug"], name: "index_event_themes_on_slug", unique: true, using: :btree
create_table "events", force: :cascade do |t| create_table "events", force: :cascade do |t|
t.string "title", limit: 255 t.string "title"
t.text "description" t.text "description"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
@ -211,10 +211,10 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "exports", ["user_id"], name: "index_exports_on_user_id", using: :btree add_index "exports", ["user_id"], name: "index_exports_on_user_id", using: :btree
create_table "friendly_id_slugs", force: :cascade do |t| create_table "friendly_id_slugs", force: :cascade do |t|
t.string "slug", limit: 255, null: false t.string "slug", null: false
t.integer "sluggable_id", null: false t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50 t.string "sluggable_type", limit: 50
t.string "scope", limit: 255 t.string "scope"
t.datetime "created_at" t.datetime "created_at"
end end
@ -224,10 +224,10 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree
create_table "groups", force: :cascade do |t| create_table "groups", force: :cascade do |t|
t.string "name", limit: 255 t.string "name"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "slug", limit: 255 t.string "slug"
t.boolean "disabled" t.boolean "disabled"
end end
@ -247,7 +247,7 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "invoice_items", force: :cascade do |t| create_table "invoice_items", force: :cascade do |t|
t.integer "invoice_id" t.integer "invoice_id"
t.string "stp_invoice_item_id", limit: 255 t.string "stp_invoice_item_id"
t.integer "amount" t.integer "amount"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
@ -261,16 +261,16 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "invoices", force: :cascade do |t| create_table "invoices", force: :cascade do |t|
t.integer "invoiced_id" t.integer "invoiced_id"
t.string "invoiced_type", limit: 255 t.string "invoiced_type"
t.string "stp_invoice_id", limit: 255 t.string "stp_invoice_id"
t.integer "total" t.integer "total"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "reference", limit: 255 t.string "reference"
t.string "avoir_mode", limit: 255 t.string "avoir_mode"
t.datetime "avoir_date" t.datetime "avoir_date"
t.integer "invoice_id" t.integer "invoice_id"
t.string "type", limit: 255 t.string "type"
t.boolean "subscription_to_expire" t.boolean "subscription_to_expire"
t.text "description" t.text "description"
t.integer "wallet_amount" t.integer "wallet_amount"
@ -299,17 +299,17 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "invoicing_profiles", ["user_id"], name: "index_invoicing_profiles_on_user_id", using: :btree add_index "invoicing_profiles", ["user_id"], name: "index_invoicing_profiles_on_user_id", using: :btree
create_table "licences", force: :cascade do |t| create_table "licences", force: :cascade do |t|
t.string "name", limit: 255, null: false t.string "name", null: false
t.text "description" t.text "description"
end end
create_table "machines", force: :cascade do |t| create_table "machines", force: :cascade do |t|
t.string "name", limit: 255, null: false t.string "name", null: false
t.text "description" t.text "description"
t.text "spec" t.text "spec"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "slug", limit: 255 t.string "slug"
t.boolean "disabled" t.boolean "disabled"
end end
@ -326,14 +326,14 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "notifications", force: :cascade do |t| create_table "notifications", force: :cascade do |t|
t.integer "receiver_id" t.integer "receiver_id"
t.integer "attached_object_id" t.integer "attached_object_id"
t.string "attached_object_type", limit: 255 t.string "attached_object_type"
t.integer "notification_type_id" t.integer "notification_type_id"
t.boolean "is_read", default: false t.boolean "is_read", default: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "receiver_type" t.string "receiver_type"
t.boolean "is_send", default: false t.boolean "is_send", default: false
t.jsonb "meta_data", default: {} t.jsonb "meta_data", default: {}
end end
add_index "notifications", ["notification_type_id"], name: "index_notifications_on_notification_type_id", using: :btree add_index "notifications", ["notification_type_id"], name: "index_notifications_on_notification_type_id", using: :btree
@ -402,20 +402,20 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "organizations", ["invoicing_profile_id"], name: "index_organizations_on_invoicing_profile_id", using: :btree add_index "organizations", ["invoicing_profile_id"], name: "index_organizations_on_invoicing_profile_id", using: :btree
create_table "plans", force: :cascade do |t| create_table "plans", force: :cascade do |t|
t.string "name", limit: 255 t.string "name"
t.integer "amount" t.integer "amount"
t.string "interval", limit: 255 t.string "interval"
t.integer "group_id" t.integer "group_id"
t.string "stp_plan_id", limit: 255 t.string "stp_plan_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "training_credit_nb", default: 0 t.integer "training_credit_nb", default: 0
t.boolean "is_rolling", default: true t.boolean "is_rolling", default: true
t.text "description" t.text "description"
t.string "type" t.string "type"
t.string "base_name" t.string "base_name"
t.integer "ui_weight", default: 0 t.integer "ui_weight", default: 0
t.integer "interval_count", default: 1 t.integer "interval_count", default: 1
t.string "slug" t.string "slug"
t.boolean "disabled" t.boolean "disabled"
end end
@ -445,11 +445,9 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "profiles", force: :cascade do |t| create_table "profiles", force: :cascade do |t|
t.integer "user_id" t.integer "user_id"
t.string "first_name", limit: 255 t.string "first_name"
t.string "last_name", limit: 255 t.string "last_name"
t.boolean "gender" t.string "phone"
t.date "birthday"
t.string "phone", limit: 255
t.text "interest" t.text "interest"
t.text "software_mastered" t.text "software_mastered"
t.datetime "created_at" t.datetime "created_at"
@ -479,7 +477,7 @@ ActiveRecord::Schema.define(version: 20190603141109) do
t.integer "project_id" t.integer "project_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "title", limit: 255 t.string "title"
t.integer "step_nb" t.integer "step_nb"
end end
@ -490,27 +488,27 @@ ActiveRecord::Schema.define(version: 20190603141109) do
t.integer "user_id" t.integer "user_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "is_valid", default: false t.boolean "is_valid", default: false
t.string "valid_token", limit: 255 t.string "valid_token"
end end
add_index "project_users", ["project_id"], name: "index_project_users_on_project_id", using: :btree add_index "project_users", ["project_id"], name: "index_project_users_on_project_id", using: :btree
add_index "project_users", ["user_id"], name: "index_project_users_on_user_id", using: :btree add_index "project_users", ["user_id"], name: "index_project_users_on_user_id", using: :btree
create_table "projects", force: :cascade do |t| create_table "projects", force: :cascade do |t|
t.string "name", limit: 255 t.string "name"
t.text "description" t.text "description"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "author_id" t.integer "author_id"
t.text "tags" t.text "tags"
t.integer "licence_id" t.integer "licence_id"
t.string "state", limit: 255 t.string "state"
t.string "slug", limit: 255 t.string "slug"
t.datetime "published_at" t.datetime "published_at"
end end
add_index "projects", ["slug"], name: "index_projects_on_slug", using: :btree add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree
create_table "projects_components", force: :cascade do |t| create_table "projects_components", force: :cascade do |t|
t.integer "project_id" t.integer "project_id"
@ -550,19 +548,19 @@ ActiveRecord::Schema.define(version: 20190603141109) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "reservable_id" t.integer "reservable_id"
t.string "reservable_type", limit: 255 t.string "reservable_type"
t.string "stp_invoice_id", limit: 255 t.string "stp_invoice_id"
t.integer "nb_reserve_places" t.integer "nb_reserve_places"
end end
add_index "reservations", ["reservable_id", "reservable_type"], name: "index_reservations_on_reservable_id_and_reservable_type", using: :btree add_index "reservations", ["reservable_type", "reservable_id"], name: "index_reservations_on_reservable_type_and_reservable_id", using: :btree
add_index "reservations", ["stp_invoice_id"], name: "index_reservations_on_stp_invoice_id", using: :btree add_index "reservations", ["stp_invoice_id"], name: "index_reservations_on_stp_invoice_id", using: :btree
add_index "reservations", ["user_id"], name: "index_reservations_on_user_id", using: :btree add_index "reservations", ["user_id"], name: "index_reservations_on_user_id", using: :btree
create_table "roles", force: :cascade do |t| create_table "roles", force: :cascade do |t|
t.string "name", limit: 255 t.string "name"
t.integer "resource_id" t.integer "resource_id"
t.string "resource_type", limit: 255 t.string "resource_type"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
@ -636,18 +634,18 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "statistic_fields", force: :cascade do |t| create_table "statistic_fields", force: :cascade do |t|
t.integer "statistic_index_id" t.integer "statistic_index_id"
t.string "key", limit: 255 t.string "key"
t.string "label", limit: 255 t.string "label"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "data_type", limit: 255 t.string "data_type"
end end
add_index "statistic_fields", ["statistic_index_id"], name: "index_statistic_fields_on_statistic_index_id", using: :btree add_index "statistic_fields", ["statistic_index_id"], name: "index_statistic_fields_on_statistic_index_id", using: :btree
create_table "statistic_graphs", force: :cascade do |t| create_table "statistic_graphs", force: :cascade do |t|
t.integer "statistic_index_id" t.integer "statistic_index_id"
t.string "chart_type", limit: 255 t.string "chart_type"
t.integer "limit" t.integer "limit"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
@ -656,17 +654,27 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "statistic_graphs", ["statistic_index_id"], name: "index_statistic_graphs_on_statistic_index_id", using: :btree add_index "statistic_graphs", ["statistic_index_id"], name: "index_statistic_graphs_on_statistic_index_id", using: :btree
create_table "statistic_indices", force: :cascade do |t| create_table "statistic_indices", force: :cascade do |t|
t.string "es_type_key", limit: 255 t.string "es_type_key"
t.string "label", limit: 255 t.string "label"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "table", default: true t.boolean "table", default: true
t.boolean "ca", default: true t.boolean "ca", default: true
end end
create_table "statistic_profiles", force: :cascade do |t|
t.boolean "gender"
t.date "birthday"
t.integer "group_id"
t.integer "user_id"
end
add_index "statistic_profiles", ["group_id"], name: "index_statistic_profiles_on_group_id", using: :btree
add_index "statistic_profiles", ["user_id"], name: "index_statistic_profiles_on_user_id", using: :btree
create_table "statistic_sub_types", force: :cascade do |t| create_table "statistic_sub_types", force: :cascade do |t|
t.string "key", limit: 255 t.string "key"
t.string "label", limit: 255 t.string "label"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
@ -683,8 +691,8 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "statistic_types", force: :cascade do |t| create_table "statistic_types", force: :cascade do |t|
t.integer "statistic_index_id" t.integer "statistic_index_id"
t.string "key", limit: 255 t.string "key"
t.string "label", limit: 255 t.string "label"
t.boolean "graph" t.boolean "graph"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
@ -702,7 +710,7 @@ ActiveRecord::Schema.define(version: 20190603141109) do
create_table "subscriptions", force: :cascade do |t| create_table "subscriptions", force: :cascade do |t|
t.integer "plan_id" t.integer "plan_id"
t.integer "user_id" t.integer "user_id"
t.string "stp_subscription_id", limit: 255 t.string "stp_subscription_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.datetime "expiration_date" t.datetime "expiration_date"
@ -721,7 +729,7 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
create_table "themes", force: :cascade do |t| create_table "themes", force: :cascade do |t|
t.string "name", limit: 255, null: false t.string "name", null: false
end end
create_table "tickets", force: :cascade do |t| create_table "tickets", force: :cascade do |t|
@ -736,13 +744,13 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "tickets", ["reservation_id"], name: "index_tickets_on_reservation_id", using: :btree add_index "tickets", ["reservation_id"], name: "index_tickets_on_reservation_id", using: :btree
create_table "trainings", force: :cascade do |t| create_table "trainings", force: :cascade do |t|
t.string "name", limit: 255 t.string "name"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "nb_total_places" t.integer "nb_total_places"
t.string "slug", limit: 255 t.string "slug"
t.text "description" t.text "description"
t.boolean "public_page", default: true t.boolean "public_page", default: true
t.boolean "disabled" t.boolean "disabled"
end end
@ -798,31 +806,31 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_index "user_trainings", ["user_id"], name: "index_user_trainings_on_user_id", using: :btree add_index "user_trainings", ["user_id"], name: "index_user_trainings_on_user_id", using: :btree
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
t.string "email", limit: 255, default: "", null: false t.string "email", default: "", null: false
t.string "encrypted_password", limit: 255, default: "", null: false t.string "encrypted_password", default: "", null: false
t.string "reset_password_token", limit: 255 t.string "reset_password_token"
t.datetime "reset_password_sent_at" t.datetime "reset_password_sent_at"
t.datetime "remember_created_at" t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at" t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at" t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255 t.string "current_sign_in_ip"
t.string "last_sign_in_ip", limit: 255 t.string "last_sign_in_ip"
t.string "confirmation_token", limit: 255 t.string "confirmation_token"
t.datetime "confirmed_at" t.datetime "confirmed_at"
t.datetime "confirmation_sent_at" t.datetime "confirmation_sent_at"
t.string "unconfirmed_email", limit: 255 t.string "unconfirmed_email"
t.integer "failed_attempts", default: 0, null: false t.integer "failed_attempts", default: 0, null: false
t.string "unlock_token", limit: 255 t.string "unlock_token"
t.datetime "locked_at" t.datetime "locked_at"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "is_allow_contact", default: true t.boolean "is_allow_contact", default: true
t.integer "group_id" t.integer "group_id"
t.string "stp_customer_id", limit: 255 t.string "stp_customer_id"
t.string "username", limit: 255 t.string "username"
t.string "slug", limit: 255 t.string "slug"
t.boolean "is_active", default: true t.boolean "is_active", default: true
t.string "provider" t.string "provider"
t.string "uid" t.string "uid"
t.string "auth_token" t.string "auth_token"
@ -911,6 +919,8 @@ ActiveRecord::Schema.define(version: 20190603141109) do
add_foreign_key "spaces_availabilities", "availabilities" add_foreign_key "spaces_availabilities", "availabilities"
add_foreign_key "spaces_availabilities", "spaces" add_foreign_key "spaces_availabilities", "spaces"
add_foreign_key "statistic_custom_aggregations", "statistic_types" add_foreign_key "statistic_custom_aggregations", "statistic_types"
add_foreign_key "statistic_profiles", "groups"
add_foreign_key "statistic_profiles", "users"
add_foreign_key "tickets", "event_price_categories" add_foreign_key "tickets", "event_price_categories"
add_foreign_key "tickets", "reservations" add_foreign_key "tickets", "reservations"
add_foreign_key "user_tags", "tags" add_foreign_key "user_tags", "tags"

View File

@ -89,7 +89,8 @@ Group.create! name: I18n.t('group.admins'), slug: 'admins' unless Group.find_by(
if Role.where(name: 'admin').joins(:users).count.zero? if Role.where(name: 'admin').joins(:users).count.zero?
admin = User.new(username: 'admin', email: ENV['ADMIN_EMAIL'], password: ENV['ADMIN_PASSWORD'], admin = User.new(username: 'admin', email: ENV['ADMIN_EMAIL'], password: ENV['ADMIN_PASSWORD'],
password_confirmation: Rails.application.secrets.admin_password, group_id: Group.find_by(slug: 'admins').id, password_confirmation: Rails.application.secrets.admin_password, group_id: Group.find_by(slug: 'admins').id,
profile_attributes: { first_name: 'admin', last_name: 'admin', gender: true, phone: '0123456789', birthday: Time.now }) profile_attributes: { first_name: 'admin', last_name: 'admin', phone: '0123456789' },
statistic_profile_attributes: { gender: true, birthday: Time.now })
admin.add_role 'admin' admin.add_role 'admin'
admin.save! admin.save!
end end

View File

@ -4,8 +4,6 @@ profile_1:
user_id: 1 user_id: 1
first_name: admin first_name: admin
last_name: admin last_name: admin
gender: true
birthday: 2016-04-04
phone: 0123456789 phone: 0123456789
interest: interest:
software_mastered: software_mastered:
@ -17,8 +15,6 @@ profile_2:
user_id: 2 user_id: 2
first_name: Jean first_name: Jean
last_name: Dupont last_name: Dupont
gender: true
birthday: 1975-06-07
phone: '0214321420' phone: '0214321420'
interest: 3D printers interest: 3D printers
software_mastered: autocad software_mastered: autocad
@ -30,8 +26,6 @@ profile_4:
user_id: 4 user_id: 4
first_name: Kevin first_name: Kevin
last_name: Dumas last_name: Dumas
gender: true
birthday: 1998-06-05
phone: 0446124793 phone: 0446124793
interest: '' interest: ''
software_mastered: solidworks software_mastered: solidworks
@ -43,8 +37,6 @@ profile_5:
user_id: 5 user_id: 5
first_name: Vanessa first_name: Vanessa
last_name: Lonchamp last_name: Lonchamp
gender: false
birthday: 1994-05-03
phone: 0233412482 phone: 0233412482
interest: vélo, natation interest: vélo, natation
software_mastered: '' software_mastered: ''
@ -56,8 +48,6 @@ profile_6:
user_id: 6 user_id: 6
first_name: Gilbert first_name: Gilbert
last_name: Partenaire last_name: Partenaire
gender: true
birthday: 2016-04-04
phone: '0000000000' phone: '0000000000'
interest: interest:
software_mastered: software_mastered:
@ -69,8 +59,6 @@ profile_3:
user_id: 3 user_id: 3
first_name: Paulette first_name: Paulette
last_name: Durand last_name: Durand
gender: false
birthday: 1949-06-18
phone: '0474264261' phone: '0474264261'
interest: '' interest: ''
software_mastered: '' software_mastered: ''
@ -82,8 +70,6 @@ profile_7:
user_id: 7 user_id: 7
first_name: Lucile first_name: Lucile
last_name: Seguin last_name: Seguin
gender: false
birthday: 1969-02-03
phone: '0241853679' phone: '0241853679'
interest: interest:
software_mastered: software_mastered:

48
test/fixtures/statistic_profiles.yml vendored Normal file
View File

@ -0,0 +1,48 @@
admin:
id: 1
user_id: 1
gender: true
birthday: 2016-04-04
group_id: 3
jdupont:
id: 2
user_id: 2
gender: true
birthday: 1975-06-07
group_id: 1
kdumas:
id: 4
user_id: 4
gender: true
birthday: 1998-06-05
group_id: 2
vlonchamp:
id: 5
user_id: 5
gender: false
birthday: 1994-05-03
group_id: 2
gpartenaire:
id: 6
user_id: 6
gender: true
birthday: 2016-04-04
group_id: 1
pdurand:
id: 3
user_id: 3
gender: false
birthday: 1949-06-18
group_id: 1
lseguin:
id: 7
user_id: 7
gender: false
birthday: 1969-02-03
group_id: 1

View File

@ -23,14 +23,16 @@ class AdminsTest < ActionDispatch::IntegrationTest
profile_attributes: { profile_attributes: {
first_name: 'Gérard', first_name: 'Gérard',
last_name: 'Lepower', last_name: 'Lepower',
gender: true, phone: '0547124852'
birthday: '1999-09-19',
phone: '0547124852',
}, },
invoicing_profile_attributes: { invoicing_profile_attributes: {
address_attributes: { address_attributes: {
address: '6 Avenue Henri de Bournazel, 19000 Tulle' address: '6 Avenue Henri de Bournazel, 19000 Tulle'
} }
},
statistic_profile_attributes: {
gender: true,
birthday: '1999-09-19'
} }
} }
}.to_json, }.to_json,

View File

@ -20,16 +20,18 @@ class MembersTest < ActionDispatch::IntegrationTest
email: email, email: email,
group_id: group_id, group_id: group_id,
profile_attributes: { profile_attributes: {
gender: true,
last_name: 'Dubois', last_name: 'Dubois',
first_name: 'Robert', first_name: 'Robert',
birthday: '2018-02-08',
phone: '0485232145' phone: '0485232145'
}, },
invoicing_profile_attributes: { invoicing_profile_attributes: {
address_attributes: { address_attributes: {
address: '21 grand rue, 73110 Bourget-en-Huile' address: '21 grand rue, 73110 Bourget-en-Huile'
} }
},
statistic_profile_attributes: {
gender: true,
birthday: '2018-02-08'
} }
} }.to_json, default_headers } }.to_json, default_headers
end end

View File

@ -1,9 +1,15 @@
# frozen_string_literal: true
require 'test_helper' require 'test_helper'
class UserTest < ActiveSupport::TestCase class UserTest < ActiveSupport::TestCase
test "must create a wallet after create user" do test 'must create wallet and profiles after create user' do
u = User.create(username: 'user', email: 'userwallet@fabmanager.com', password: 'testpassword', password_confirmation: 'testpassword', u = User.create(username: 'user', email: 'userwallet@fabmanager.com', password: 'testpassword', password_confirmation: 'testpassword',
profile_attributes: {first_name: 'user', last_name: 'wallet', gender: true, birthday: 18.years.ago, phone: '0123456789'} ) profile_attributes: { first_name: 'user', last_name: 'wallet', phone: '0123456789' },
statistic_profile_attributes: { gender: true, birthday: 18.years.ago })
assert u.wallet.present? assert u.wallet.present?
assert u.profile.present?
assert u.invoicing_profile.present?
assert u.statistic_profile.present?
end end
end end