saucy 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,16 @@
1
+ 0.8.2
2
+
3
+ Added a uniqueness validation and database constraint for member_id/project_id on permissions. This prevents somebody from being added to the same project twice, which would display it multiple times in the project index and dropdown. When upgrading, make sure this index is in place:
4
+
5
+ remove_index :permissions, :name => [:membership_and_project]
6
+ add_index :permissions, [:membership_id, :project_id], :name => [:membership_and_project], :unique => true
7
+
8
+ You'll need to make sure that no existing duplicates exist before applying the unique index.
9
+
10
+ 0.8.1
11
+
12
+ Fixed a missing translation key.
13
+
1
14
  0.8.0
2
15
 
3
16
  Added a notification for trials that just ended. When upgrading, you'll need to
@@ -5,6 +5,8 @@ class Permission < ActiveRecord::Base
5
5
 
6
6
  before_validation :assign_user_id_from_membership
7
7
 
8
+ validates_uniqueness_of :membership_id, :scope => :project_id
9
+
8
10
  def user=(ignored)
9
11
  raise NotImplementedError, "Use Permission#membership= instead"
10
12
  end
@@ -55,7 +55,7 @@ class CreateSaucyTables < ActiveRecord::Migration
55
55
  end
56
56
 
57
57
  add_index :permissions, [:user_id, :project_id]
58
- add_index :permissions, [:membership_id, :project_id], :name => [:membership_and_project]
58
+ add_index :permissions, [:membership_id, :project_id], :name => [:membership_and_project], :unique => true
59
59
 
60
60
  create_table :projects do |table|
61
61
  table.string :name
@@ -5,10 +5,21 @@ describe Permission do
5
5
  it { should belong_to(:membership) }
6
6
  it { should belong_to(:user) }
7
7
 
8
+ it "doesn't allow the same member to be added to a project twice" do
9
+ original = Factory(:permission)
10
+ duplicate = Factory.build(:permission, :membership => original.membership, :project => original.project)
11
+ duplicate.should_not be_valid
12
+ end
13
+
14
+ it "allows different members to be added to a project" do
15
+ original = Factory(:permission)
16
+ duplicate = Factory.build(:permission, :project => original.project)
17
+ duplicate.should be_valid
18
+ end
19
+
8
20
  it "caches the user from the account membership" do
9
21
  membership = Factory(:membership)
10
- permission = Factory(:permission,
11
- :membership => membership)
22
+ permission = Factory(:permission, :membership => membership)
12
23
  permission.user_id.should == membership.user_id
13
24
  end
14
25
 
@@ -171,29 +171,29 @@ describe Project, "assigning users on update" do
171
171
  subject { Factory(:project) }
172
172
 
173
173
  let(:account) { subject.account }
174
- let!(:member) { Factory(:user) }
175
- let!(:non_member) { Factory(:user) }
174
+ let!(:user_to_remove) { Factory(:user) }
175
+ let!(:user_to_add) { Factory(:user) }
176
176
  let!(:admin) { Factory(:user) }
177
177
 
178
178
  before do
179
- member_membership =
180
- Factory(:membership, :account => account, :user => member)
181
- non_member_membership =
182
- Factory(:membership, :account => account, :user => non_member)
179
+ membership_to_remove =
180
+ Factory(:membership, :account => account, :user => user_to_remove)
181
+ membership_to_add =
182
+ Factory(:membership, :account => account, :user => user_to_add)
183
183
  admin_membership =
184
184
  Factory(:membership, :account => account, :user => admin, :admin => true)
185
- Factory(:permission, :membership => member_membership,
185
+ Factory(:permission, :membership => membership_to_remove,
186
186
  :project => subject)
187
187
 
188
- subject.reload.update_attributes!(:user_ids => [non_member.id, ""])
188
+ subject.reload.update_attributes!(:user_ids => [user_to_add.id, ""])
189
189
  end
190
190
 
191
191
  it "adds an added user" do
192
- member.should_not be_member_of(subject)
192
+ user_to_add.should be_member_of(subject)
193
193
  end
194
194
 
195
195
  it "removes a removed user" do
196
- non_member.should be_member_of(subject)
196
+ user_to_remove.should_not be_member_of(subject)
197
197
  end
198
198
 
199
199
  it "keeps an admin" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saucy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 1
10
- version: 0.8.1
9
+ - 2
10
+ version: 0.8.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - thoughtbot, inc.
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-05-10 00:00:00 -04:00
21
+ date: 2011-06-07 00:00:00 -04:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency