aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinhui2016-08-08 11:16:59 +0200
committerXinhui2016-08-08 11:16:59 +0200
commitfabaf9b63e9cb7ecb0f4cd84bb15fda536e8f5b3 (patch)
treeea1186491d9a6db968943e421652feaa15f23fe2
parentac6af39ce23b917e62b29b52396f8eb9e68e5e5c (diff)
downloadchouette-core-fabaf9b63e9cb7ecb0f4cd84bb15fda536e8f5b3.tar.bz2
Set :lockable to model User
-rw-r--r--app/models/user.rb2
-rw-r--r--lib/tasks/users.rake1
-rw-r--r--spec/fixtures/users.json11
-rw-r--r--spec/task/users_rake_spec.rb7
-rw-r--r--users.json144
5 files changed, 164 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 3233b5efb..3262001f3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -5,7 +5,7 @@ class User < ActiveRecord::Base
@@authentication_type = "#{Rails.application.config.chouette_authentication_settings[:type]}_authenticatable".to_sym
cattr_reader :authentication_type
- devise :invitable, :registerable, :validatable,
+ devise :invitable, :registerable, :validatable, :lockable,
:recoverable, :rememberable, :trackable, :async, authentication_type
# FIXME https://github.com/nbudin/devise_cas_authenticatable/issues/53
diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake
index cc2f17103..76250f0f0 100644
--- a/lib/tasks/users.rake
+++ b/lib/tasks/users.rake
@@ -21,6 +21,7 @@ namespace :users do
User.find_or_create_by(username: el['username']).tap do |user|
user.name = "#{el['firstname']} #{el['lastname']}"
user.email = el['email']
+ user.locked_at = el['locked_at']
user.synced_at = Time.now
# Set organisation
diff --git a/spec/fixtures/users.json b/spec/fixtures/users.json
index f78e1c445..d5affc81b 100644
--- a/spec/fixtures/users.json
+++ b/spec/fixtures/users.json
@@ -7,6 +7,7 @@
"phone_number": null,
"created_at": "2016-08-05T12:33:45.152Z",
"updated_at": "2016-08-05T12:33:45.152Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -19,6 +20,7 @@
"phone_number": "+336 69 25 15 71",
"created_at": "2016-08-05T12:34:03.049Z",
"updated_at": "2016-08-05T12:34:03.049Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -31,6 +33,7 @@
"phone_number": "0697099622",
"created_at": "2016-08-05T12:34:03.161Z",
"updated_at": "2016-08-05T12:34:03.161Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -43,6 +46,7 @@
"phone_number": "0033778300069",
"created_at": "2016-08-05T12:34:03.256Z",
"updated_at": "2016-08-05T12:34:03.256Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -55,6 +59,7 @@
"phone_number": "0302098171",
"created_at": "2016-08-05T12:34:03.360Z",
"updated_at": "2016-08-05T12:34:03.360Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -67,6 +72,7 @@
"phone_number": "0033763987210",
"created_at": "2016-08-05T12:34:03.457Z",
"updated_at": "2016-08-05T12:34:03.457Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -79,6 +85,7 @@
"phone_number": "0033790632621",
"created_at": "2016-08-05T12:34:03.553Z",
"updated_at": "2016-08-05T12:34:03.553Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -91,6 +98,7 @@
"phone_number": "+33799062141",
"created_at": "2016-08-05T12:34:03.649Z",
"updated_at": "2016-08-05T12:34:03.649Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -103,6 +111,7 @@
"phone_number": "+33614563995",
"created_at": "2016-08-05T12:34:03.756Z",
"updated_at": "2016-08-05T12:34:03.756Z",
+ "locked_at": null,
"profile": "Administrateur",
"organization_name": "STIF",
"organization_code": "STIF"
@@ -115,6 +124,7 @@
"phone_number": "00337 67 87 93 02",
"created_at": "2016-08-05T12:34:03.894Z",
"updated_at": "2016-08-05T12:34:03.894Z",
+ "locked_at": null,
"profile": "Référent IV Transporteur",
"organization_name": "RATP",
"organization_code": "RATP"
@@ -127,6 +137,7 @@
"phone_number": "+337 07 54 55 73",
"created_at": "2016-08-05T12:34:03.995Z",
"updated_at": "2016-08-05T12:34:03.995Z",
+ "locked_at": "2016-08-05T12:34:03.995Z",
"profile": "Référent IV Transporteur",
"organization_name": "RATP",
"organization_code": "RATP"
diff --git a/spec/task/users_rake_spec.rb b/spec/task/users_rake_spec.rb
index d7c2ed8c9..7f6d3adb5 100644
--- a/spec/task/users_rake_spec.rb
+++ b/spec/task/users_rake_spec.rb
@@ -39,6 +39,13 @@ describe 'users:sync rake task' do
expect(user.synced_at.utc).to be_within(1.second).of Time.now
end
+ it 'should update locked_at attribute' do
+ create :user, username: 'alban.peignier', locked_at: Time.now
+ run_rake_task
+ expect(User.find_by(username: 'alban.peignier').locked_at).to be_nil
+ expect(User.find_by(username: 'jane.doe').locked_at).to eq("2016-08-05T12:34:03.995Z")
+ end
+
it 'should not create new user if username is already present' do
create :user, username: 'alban.peignier'
run_rake_task
diff --git a/users.json b/users.json
new file mode 100644
index 000000000..d5affc81b
--- /dev/null
+++ b/users.json
@@ -0,0 +1,144 @@
+[{
+ "id": 1,
+ "username": "admin",
+ "email": "stif-portail@af83.com",
+ "firstname": "admin",
+ "lastname": "stif",
+ "phone_number": null,
+ "created_at": "2016-08-05T12:33:45.152Z",
+ "updated_at": "2016-08-05T12:33:45.152Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 2,
+ "username": "luc.donnet",
+ "email": "luc.donnet@af83.com",
+ "firstname": "Luc",
+ "lastname": "Donnet",
+ "phone_number": "+336 69 25 15 71",
+ "created_at": "2016-08-05T12:34:03.049Z",
+ "updated_at": "2016-08-05T12:34:03.049Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 3,
+ "username": "alban.peignier",
+ "email": "alban.peignier@af83.com",
+ "firstname": "Alban",
+ "lastname": "Peignier",
+ "phone_number": "0697099622",
+ "created_at": "2016-08-05T12:34:03.161Z",
+ "updated_at": "2016-08-05T12:34:03.161Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 4,
+ "username": "pierre.vabre",
+ "email": "pierre.vabre@af83.com",
+ "firstname": "Pierre",
+ "lastname": "Vabre",
+ "phone_number": "0033778300069",
+ "created_at": "2016-08-05T12:34:03.256Z",
+ "updated_at": "2016-08-05T12:34:03.256Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 5,
+ "username": "laure.dubuc",
+ "email": "laure.dubuc@af83.com",
+ "firstname": "Laure",
+ "lastname": "Dubuc",
+ "phone_number": "0302098171",
+ "created_at": "2016-08-05T12:34:03.360Z",
+ "updated_at": "2016-08-05T12:34:03.360Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 6,
+ "username": "thomas.haddad",
+ "email": "thomas.haddad@af83.com",
+ "firstname": "Thomas",
+ "lastname": "Haddad",
+ "phone_number": "0033763987210",
+ "created_at": "2016-08-05T12:34:03.457Z",
+ "updated_at": "2016-08-05T12:34:03.457Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 7,
+ "username": "jean-paul.lescouzeres",
+ "email": "jean-paul.lescouzeres@af83.com",
+ "firstname": "Jean-Paul",
+ "lastname": "Lescouzères",
+ "phone_number": "0033790632621",
+ "created_at": "2016-08-05T12:34:03.553Z",
+ "updated_at": "2016-08-05T12:34:03.553Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 8,
+ "username": "xinhui.xu",
+ "email": "xinhui.xu@af83.com",
+ "firstname": "Xinhui",
+ "lastname": "Xu",
+ "phone_number": "+33799062141",
+ "created_at": "2016-08-05T12:34:03.649Z",
+ "updated_at": "2016-08-05T12:34:03.649Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 9,
+ "username": "edouard.maffert",
+ "email": "edouard.maffert@af83.com",
+ "firstname": "Edouard",
+ "lastname": "Maffert",
+ "phone_number": "+33614563995",
+ "created_at": "2016-08-05T12:34:03.756Z",
+ "updated_at": "2016-08-05T12:34:03.756Z",
+ "locked_at": null,
+ "profile": "Administrateur",
+ "organization_name": "STIF",
+ "organization_code": "STIF"
+}, {
+ "id": 10,
+ "username": "john.doe",
+ "email": "john.doe@af83.com",
+ "firstname": "John",
+ "lastname": "Doe",
+ "phone_number": "00337 67 87 93 02",
+ "created_at": "2016-08-05T12:34:03.894Z",
+ "updated_at": "2016-08-05T12:34:03.894Z",
+ "locked_at": null,
+ "profile": "Référent IV Transporteur",
+ "organization_name": "RATP",
+ "organization_code": "RATP"
+}, {
+ "id": 11,
+ "username": "jane.doe",
+ "email": "jane.doe@af83.com",
+ "firstname": "Jane",
+ "lastname": "Doe",
+ "phone_number": "+337 07 54 55 73",
+ "created_at": "2016-08-05T12:34:03.995Z",
+ "updated_at": "2016-08-05T12:34:03.995Z",
+ "locked_at": "2016-08-05T12:34:03.995Z",
+ "profile": "Référent IV Transporteur",
+ "organization_name": "RATP",
+ "organization_code": "RATP"
+}]