roles_active_record 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb +1 -1
- data/lib/generators/active_record/roles_migration/templates/add_one_role_strategy.erb +1 -1
- data/roles_active_record.gemspec +10 -12
- data/spec/migrations/admin_flag/{004_add_admin_flag_to_users.rb → 002_add_admin_flag_strategy.rb} +1 -3
- data/spec/migrations/many_roles/002_add_many_roles_strategy.rb +54 -0
- data/spec/migrations/role_string/{002_add_role_string_to_users.rb → 002_add_role_string_strategy.rb} +1 -1
- data/spec/migrations/roles_mask/{005_add_roles_mask_to_users.rb → 002_add_roles_mask_strategy.rb} +1 -1
- metadata +11 -13
- data/spec/migrations/many_roles/002_create_roles.rb +0 -12
- data/spec/migrations/many_roles/003_create_user_roles.rb +0 -13
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/roles_active_record.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{roles_active_record}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-20}
|
13
13
|
s.description = %q{Makes it easy to set a role strategy on your User model in Active Record}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -68,12 +68,11 @@ Gem::Specification.new do |s|
|
|
68
68
|
"spec/fixtures/one_role_setup_unique_check.rb",
|
69
69
|
"spec/generator_spec_helper.rb",
|
70
70
|
"spec/migration_spec_helper.rb",
|
71
|
-
"spec/migrations/admin_flag/
|
72
|
-
"spec/migrations/many_roles/
|
73
|
-
"spec/migrations/many_roles/003_create_user_roles.rb",
|
71
|
+
"spec/migrations/admin_flag/002_add_admin_flag_strategy.rb",
|
72
|
+
"spec/migrations/many_roles/002_add_many_roles_strategy.rb",
|
74
73
|
"spec/migrations/one_role/002_add_one_role_strategy.rb",
|
75
|
-
"spec/migrations/role_string/
|
76
|
-
"spec/migrations/roles_mask/
|
74
|
+
"spec/migrations/role_string/002_add_role_string_strategy.rb",
|
75
|
+
"spec/migrations/roles_mask/002_add_roles_mask_strategy.rb",
|
77
76
|
"spec/migrations/users/001_create_users.rb",
|
78
77
|
"spec/roles_active_record/generators/roles_generator_spec.rb",
|
79
78
|
"spec/roles_active_record/generators/roles_migration/admin_flag_spec.rb",
|
@@ -113,12 +112,11 @@ Gem::Specification.new do |s|
|
|
113
112
|
"spec/fixtures/one_role_setup_unique_check.rb",
|
114
113
|
"spec/generator_spec_helper.rb",
|
115
114
|
"spec/migration_spec_helper.rb",
|
116
|
-
"spec/migrations/admin_flag/
|
117
|
-
"spec/migrations/many_roles/
|
118
|
-
"spec/migrations/many_roles/003_create_user_roles.rb",
|
115
|
+
"spec/migrations/admin_flag/002_add_admin_flag_strategy.rb",
|
116
|
+
"spec/migrations/many_roles/002_add_many_roles_strategy.rb",
|
119
117
|
"spec/migrations/one_role/002_add_one_role_strategy.rb",
|
120
|
-
"spec/migrations/role_string/
|
121
|
-
"spec/migrations/roles_mask/
|
118
|
+
"spec/migrations/role_string/002_add_role_string_strategy.rb",
|
119
|
+
"spec/migrations/roles_mask/002_add_roles_mask_strategy.rb",
|
122
120
|
"spec/migrations/users/001_create_users.rb",
|
123
121
|
"spec/roles_active_record/generators/roles_generator_spec.rb",
|
124
122
|
"spec/roles_active_record/generators/roles_migration/admin_flag_spec.rb",
|
data/spec/migrations/admin_flag/{004_add_admin_flag_to_users.rb → 002_add_admin_flag_strategy.rb}
RENAMED
@@ -1,15 +1,13 @@
|
|
1
|
-
class
|
1
|
+
class AddAdminFlagStrategy < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
change_table :users do |t|
|
4
4
|
t.boolean :admin_flag, :default => false
|
5
5
|
end
|
6
|
-
# add_column :users, :admin_flag, :boolean, :default => false
|
7
6
|
end
|
8
7
|
|
9
8
|
def self.down
|
10
9
|
change_table :users do |t|
|
11
10
|
t.remove :admin_flag
|
12
11
|
end
|
13
|
-
# remove_column :users, :admin_flag
|
14
12
|
end
|
15
13
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class AddManyRolesStrategy < ActiveRecord::Migration
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def up
|
5
|
+
create_roles
|
6
|
+
create_user_roles
|
7
|
+
add_index :roles, :name, :unique => true
|
8
|
+
|
9
|
+
# insert_roles
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
drop_roles
|
14
|
+
drop_user_roles
|
15
|
+
|
16
|
+
remove_index :roles, :name
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def create_user_roles
|
22
|
+
create_table :user_roles do |t|
|
23
|
+
t.integer :user_id
|
24
|
+
t.integer :role_id
|
25
|
+
t.timestamps
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def drop_user_roles
|
30
|
+
drop_table :user_roles
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def create_roles
|
35
|
+
create_table :roles do |t|
|
36
|
+
t.string :name
|
37
|
+
t.timestamps
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def drop_roles
|
42
|
+
drop_table :roles
|
43
|
+
end
|
44
|
+
|
45
|
+
def insert_roles
|
46
|
+
roles_to_add.each do |role|
|
47
|
+
begin
|
48
|
+
Role.create(:name => "#{role}")
|
49
|
+
rescue
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 6
|
9
|
+
version: 0.3.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-20 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -390,12 +390,11 @@ files:
|
|
390
390
|
- spec/fixtures/one_role_setup_unique_check.rb
|
391
391
|
- spec/generator_spec_helper.rb
|
392
392
|
- spec/migration_spec_helper.rb
|
393
|
-
- spec/migrations/admin_flag/
|
394
|
-
- spec/migrations/many_roles/
|
395
|
-
- spec/migrations/many_roles/003_create_user_roles.rb
|
393
|
+
- spec/migrations/admin_flag/002_add_admin_flag_strategy.rb
|
394
|
+
- spec/migrations/many_roles/002_add_many_roles_strategy.rb
|
396
395
|
- spec/migrations/one_role/002_add_one_role_strategy.rb
|
397
|
-
- spec/migrations/role_string/
|
398
|
-
- spec/migrations/roles_mask/
|
396
|
+
- spec/migrations/role_string/002_add_role_string_strategy.rb
|
397
|
+
- spec/migrations/roles_mask/002_add_roles_mask_strategy.rb
|
399
398
|
- spec/migrations/users/001_create_users.rb
|
400
399
|
- spec/roles_active_record/generators/roles_generator_spec.rb
|
401
400
|
- spec/roles_active_record/generators/roles_migration/admin_flag_spec.rb
|
@@ -462,12 +461,11 @@ test_files:
|
|
462
461
|
- spec/fixtures/one_role_setup_unique_check.rb
|
463
462
|
- spec/generator_spec_helper.rb
|
464
463
|
- spec/migration_spec_helper.rb
|
465
|
-
- spec/migrations/admin_flag/
|
466
|
-
- spec/migrations/many_roles/
|
467
|
-
- spec/migrations/many_roles/003_create_user_roles.rb
|
464
|
+
- spec/migrations/admin_flag/002_add_admin_flag_strategy.rb
|
465
|
+
- spec/migrations/many_roles/002_add_many_roles_strategy.rb
|
468
466
|
- spec/migrations/one_role/002_add_one_role_strategy.rb
|
469
|
-
- spec/migrations/role_string/
|
470
|
-
- spec/migrations/roles_mask/
|
467
|
+
- spec/migrations/role_string/002_add_role_string_strategy.rb
|
468
|
+
- spec/migrations/roles_mask/002_add_roles_mask_strategy.rb
|
471
469
|
- spec/migrations/users/001_create_users.rb
|
472
470
|
- spec/roles_active_record/generators/roles_generator_spec.rb
|
473
471
|
- spec/roles_active_record/generators/roles_migration/admin_flag_spec.rb
|