adhocracy 0.3.1 → 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGRlNDFlNTc1OWVlZTQ1ZjcwOTQyNjgzZTI1NWM3OGYwNDdlOTAxMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmUwMDlmNDlhZmM0NWY2NTZmZWQ1ZTU2N2JiNTUwMDAxYzUzNzkyOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDY3ODIxNGNjNDAwZDZkYzliMWE0OTAzZmExMzEzOGVkZTQ3YWQzMTcwZWU0
|
10
|
+
N2I5OGJmMWY5MTAxMDM2Nzg1NWU0ZDdkOWRlNTE0ZjQ3OGIwZTZlN2I4YzY2
|
11
|
+
NjJmZThiNzhmMDkwMmRkZjY5OWZjNjQ3ZWVlZGZjOWI5YzEzNWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTYxNzQ5ZGVjNzkxYjNjZWU4YWQ0NGRjZWU1ZmU3MGFmNmFiM2FjNWQ3NTli
|
14
|
+
NjY3YThiZGM0NzA4YWRlOWJlYTgwOWYyMGM3ZGI0MjRjNmJhODM5OWFlYjU2
|
15
|
+
ZWIzYjM3MTk2NGIzMGVkOGVlMmM1ZTFhMjk3MjVkMzAyYzRkOWM=
|
@@ -4,6 +4,11 @@ module Adhocracy
|
|
4
4
|
belongs_to :group, polymorphic: true
|
5
5
|
|
6
6
|
validate :membership_is_unique
|
7
|
+
before_destroy :member_is_not_only_officer
|
8
|
+
|
9
|
+
def is_necessary_officer?
|
10
|
+
officer? && group.officers.length <= 1
|
11
|
+
end
|
7
12
|
|
8
13
|
private
|
9
14
|
def membership_is_unique
|
@@ -11,5 +16,9 @@ module Adhocracy
|
|
11
16
|
errors[:base] << I18n.t("activerecord.errors.models.membership.not_unique")
|
12
17
|
end
|
13
18
|
end
|
19
|
+
|
20
|
+
def member_is_not_only_officer
|
21
|
+
return false if is_necessary_officer?
|
22
|
+
end
|
14
23
|
end
|
15
24
|
end
|
@@ -56,7 +56,8 @@ module Adhocracy
|
|
56
56
|
|
57
57
|
def demote_officer(member)
|
58
58
|
membership = Adhocracy::Membership.find_by(member: member, group: self)
|
59
|
-
return false if !membership.present? || !membership.officer?
|
59
|
+
return false if !membership.present? || !membership.officer? ||
|
60
|
+
membership.is_necessary_officer?
|
60
61
|
return membership.update_column(:officer, false)
|
61
62
|
end
|
62
63
|
|
data/lib/adhocracy/version.rb
CHANGED
@@ -17,5 +17,43 @@ module Adhocracy
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
context "must have at least one officer" do
|
21
|
+
before :each do
|
22
|
+
@adhoc = FactoryGirl.create(:adhoc)
|
23
|
+
@officer_1 = FactoryGirl.create(:user)
|
24
|
+
@member = FactoryGirl.create(:user)
|
25
|
+
@officer_1_membership = @adhoc.add_officer(@officer_1)
|
26
|
+
@member_membership = @adhoc.add_member(@member)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "which cannot be removed" do
|
30
|
+
@adhoc.remove_member(@officer_1)
|
31
|
+
expect(@adhoc.has_officer?(@officer_1)).to be true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "which cannot be demoted" do
|
35
|
+
@adhoc.demote_officer(@officer_1)
|
36
|
+
expect(@adhoc.has_officer?(@officer_1)).to be true
|
37
|
+
end
|
38
|
+
|
39
|
+
context "but if there is more than one" do
|
40
|
+
|
41
|
+
before :each do
|
42
|
+
@officer_2 = FactoryGirl.create(:user)
|
43
|
+
@officer_2_membership = @adhoc.add_officer(@officer_2)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "an officer can be removed" do
|
47
|
+
@adhoc.remove_member(@officer_1)
|
48
|
+
expect(@adhoc.has_officer?(@officer_1)).to be false
|
49
|
+
end
|
50
|
+
|
51
|
+
it "an officer can be demoted" do
|
52
|
+
@adhoc.demote_officer(@officer_1)
|
53
|
+
expect(@adhoc.has_officer?(@officer_1)).to be false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
20
58
|
end
|
21
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adhocracy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- timothycommoner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -253,50 +253,50 @@ signing_key:
|
|
253
253
|
specification_version: 4
|
254
254
|
summary: Adhocracy is group management engine for Rails.
|
255
255
|
test_files:
|
256
|
-
- spec/
|
256
|
+
- spec/models/adhocracy/membership_invitation_spec.rb
|
257
|
+
- spec/models/adhocracy/membership_spec.rb
|
258
|
+
- spec/models/adhocracy/membership_request_spec.rb
|
259
|
+
- spec/factories/adhocracy_membership_requests.rb
|
260
|
+
- spec/factories/adhocracy_memberships.rb
|
261
|
+
- spec/factories/users.rb
|
262
|
+
- spec/factories/adhoc.rb
|
263
|
+
- spec/factories/adhocracy_membership_invitations.rb
|
257
264
|
- spec/lib/adhocracy/acts_as_member_spec.rb
|
258
|
-
- spec/
|
259
|
-
- spec/dummy/
|
260
|
-
- spec/dummy/
|
261
|
-
- spec/dummy/
|
262
|
-
- spec/dummy/config.ru
|
263
|
-
- spec/dummy/db/schema.rb
|
264
|
-
- spec/dummy/db/migrate/20140306214611_create_users.rb
|
265
|
-
- spec/dummy/db/migrate/20140306214620_create_adhocs.rb
|
266
|
-
- spec/dummy/config/routes.rb
|
267
|
-
- spec/dummy/config/application.rb
|
268
|
-
- spec/dummy/config/environments/test.rb
|
269
|
-
- spec/dummy/config/environments/development.rb
|
270
|
-
- spec/dummy/config/environments/production.rb
|
265
|
+
- spec/lib/adhocracy/acts_as_group_spec.rb
|
266
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
267
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
268
|
+
- spec/dummy/config/initializers/inflections.rb
|
271
269
|
- spec/dummy/config/initializers/mime_types.rb
|
272
270
|
- spec/dummy/config/initializers/session_store.rb
|
273
271
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
274
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
275
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
276
272
|
- spec/dummy/config/initializers/secret_token.rb
|
277
|
-
- spec/dummy/config/initializers/inflections.rb
|
278
273
|
- spec/dummy/config/boot.rb
|
274
|
+
- spec/dummy/config/application.rb
|
279
275
|
- spec/dummy/config/database.yml
|
276
|
+
- spec/dummy/config/environments/development.rb
|
277
|
+
- spec/dummy/config/environments/test.rb
|
278
|
+
- spec/dummy/config/environments/production.rb
|
280
279
|
- spec/dummy/config/locales/en.yml
|
281
280
|
- spec/dummy/config/environment.rb
|
281
|
+
- spec/dummy/config/routes.rb
|
282
|
+
- spec/dummy/db/schema.rb
|
283
|
+
- spec/dummy/db/migrate/20140306214611_create_users.rb
|
284
|
+
- spec/dummy/db/migrate/20140306214620_create_adhocs.rb
|
282
285
|
- spec/dummy/Rakefile
|
283
|
-
- spec/dummy/public/500.html
|
284
|
-
- spec/dummy/public/404.html
|
285
|
-
- spec/dummy/public/422.html
|
286
|
-
- spec/dummy/public/favicon.ico
|
287
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
288
286
|
- spec/dummy/app/helpers/application_helper.rb
|
289
|
-
- spec/dummy/app/assets/javascripts/application.js
|
290
287
|
- spec/dummy/app/assets/stylesheets/application.css
|
288
|
+
- spec/dummy/app/assets/javascripts/application.js
|
291
289
|
- spec/dummy/app/controllers/application_controller.rb
|
292
|
-
- spec/dummy/app/models/user.rb
|
293
290
|
- spec/dummy/app/models/adhoc.rb
|
294
|
-
- spec/
|
295
|
-
- spec/
|
296
|
-
- spec/
|
297
|
-
- spec/
|
298
|
-
- spec/
|
291
|
+
- spec/dummy/app/models/user.rb
|
292
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
293
|
+
- spec/dummy/config.ru
|
294
|
+
- spec/dummy/README.rdoc
|
295
|
+
- spec/dummy/public/422.html
|
296
|
+
- spec/dummy/public/404.html
|
297
|
+
- spec/dummy/public/500.html
|
298
|
+
- spec/dummy/public/favicon.ico
|
299
|
+
- spec/dummy/bin/rake
|
300
|
+
- spec/dummy/bin/rails
|
301
|
+
- spec/dummy/bin/bundle
|
299
302
|
- spec/spec_helper.rb
|
300
|
-
- spec/models/adhocracy/membership_invitation_spec.rb
|
301
|
-
- spec/models/adhocracy/membership_spec.rb
|
302
|
-
- spec/models/adhocracy/membership_request_spec.rb
|