diff --git a/app/models/organization.rb b/app/models/organization.rb index eeacd48..0e02b93 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -157,4 +157,8 @@ class Organization < Profile members_by_role(role).map { |member| {:id => member.id, :name => member.name} }.to_json end + def disable + self.visible = false + save! + end end diff --git a/app/models/person.rb b/app/models/person.rb index 6fee0f5..6c3c609 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -406,6 +406,14 @@ class Person < Profile {:title => _('Profile Info and settings'), :icon => 'edit-profile'} end + def disable + self.visible = false + user.password = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{identifier}--") + user.password_confirmation = user.password + save! + user.save! + end + protected def followed_by?(profile) diff --git a/app/models/profile.rb b/app/models/profile.rb index d276438..4467bc6 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -806,11 +806,6 @@ private :generate_url, :url_options end def disable - self.visible = false - user.password = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{identifier}--") - user.password_confirmation = user.password - save! - user.save! end def control_panel_settings_button diff --git a/test/unit/organization_test.rb b/test/unit/organization_test.rb index e701d82..1080609 100644 --- a/test/unit/organization_test.rb +++ b/test/unit/organization_test.rb @@ -408,4 +408,12 @@ class OrganizationTest < Test::Unit::TestCase assert_match [{:id => p1.id, :name => p1.name}, {:id => p2.id, :name => p2.name}].to_json, organization.members_by_role_to_json(role) end + should 'disable organization' do + organization = fast_create(Organization, :visible => true) + assert organization.visible + + organization.disable + assert !organization.visible + end + end diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 9632b60..751779c 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -1227,4 +1227,14 @@ class PersonTest < Test::Unit::TestCase assert person.already_reported?(profile) end + should 'disable person' do + person = create_user('some-user').person + password = person.user.password + assert person.visible + + person.disable + + assert !person.visible + assert_not_equal password, person.user.password + end end -- libgit2 0.21.2