milia 1.2.1 → 1.3.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/confirmations_controller.rb +7 -7
  3. data/app/controllers/registrations_controller.rb +13 -19
  4. data/app/views/devise/registrations/new.html.haml +53 -0
  5. data/lib/generators/milia/install_generator.rb +44 -41
  6. data/lib/generators/milia/templates/devise_permitted_parameters.rb +18 -0
  7. data/lib/generators/milia/templates/initializer.rb +3 -9
  8. data/lib/milia.rb +3 -22
  9. data/lib/milia/base.rb +88 -109
  10. data/lib/milia/control.rb +25 -25
  11. data/lib/milia/invite_member.rb +6 -6
  12. data/lib/milia/version.rb +1 -1
  13. metadata +16 -184
  14. data/.document +0 -5
  15. data/.gitignore +0 -94
  16. data/.ruby-gemset +0 -1
  17. data/.ruby-version +0 -1
  18. data/.slugignore +0 -2
  19. data/.travis.yml +0 -4
  20. data/Gemfile +0 -4
  21. data/LICENSE.txt +0 -20
  22. data/README.md +0 -1207
  23. data/Rakefile +0 -1
  24. data/doc/gemfile_addition.txt +0 -28
  25. data/doc/manual_sample.sh +0 -816
  26. data/doc/ref_notes.txt +0 -155
  27. data/doc/sample.sh +0 -276
  28. data/markdown.rb +0 -38
  29. data/milia.gemspec +0 -29
  30. data/test/.ruby-gemset +0 -1
  31. data/test/.ruby-version +0 -1
  32. data/test/Gemfile +0 -81
  33. data/test/Gemfile.lock +0 -223
  34. data/test/README.md +0 -83
  35. data/test/Rakefile +0 -6
  36. data/test/app/assets/javascripts/application.js +0 -16
  37. data/test/app/assets/stylesheets/application.css +0 -13
  38. data/test/app/controllers/application_controller.rb +0 -13
  39. data/test/app/controllers/home_controller.rb +0 -10
  40. data/test/app/helpers/application_helper.rb +0 -2
  41. data/test/app/models/member.rb +0 -34
  42. data/test/app/models/post.rb +0 -14
  43. data/test/app/models/team.rb +0 -9
  44. data/test/app/models/team_asset.rb +0 -6
  45. data/test/app/models/tenant.rb +0 -54
  46. data/test/app/models/user.rb +0 -14
  47. data/test/app/models/zine.rb +0 -8
  48. data/test/app/views/home/index.html.erb +0 -2
  49. data/test/app/views/home/show.html.erb +0 -2
  50. data/test/app/views/layouts/application.html.erb +0 -14
  51. data/test/bin/bundle +0 -3
  52. data/test/bin/rails +0 -4
  53. data/test/bin/rake +0 -4
  54. data/test/config/application.rb +0 -36
  55. data/test/config/boot.rb +0 -4
  56. data/test/config/database.yml +0 -25
  57. data/test/config/environment.rb +0 -5
  58. data/test/config/environments/development.rb +0 -48
  59. data/test/config/environments/production.rb +0 -95
  60. data/test/config/environments/test.rb +0 -42
  61. data/test/config/initializers/backtrace_silencers.rb +0 -7
  62. data/test/config/initializers/devise.rb +0 -254
  63. data/test/config/initializers/filter_parameter_logging.rb +0 -4
  64. data/test/config/initializers/inflections.rb +0 -16
  65. data/test/config/initializers/milia.rb +0 -51
  66. data/test/config/initializers/mime_types.rb +0 -5
  67. data/test/config/initializers/secret_token.rb +0 -12
  68. data/test/config/initializers/session_store.rb +0 -3
  69. data/test/config/initializers/wrap_parameters.rb +0 -14
  70. data/test/config/locales/en.yml +0 -23
  71. data/test/config/routes.rb +0 -77
  72. data/test/db/migrate/20111012050200_add_sessions_table.rb +0 -12
  73. data/test/db/migrate/20111012050340_devise_create_users.rb +0 -48
  74. data/test/db/migrate/20111012050532_create_tenants.rb +0 -11
  75. data/test/db/migrate/20111012050600_create_tenants_users_join_table.rb +0 -8
  76. data/test/db/migrate/20111012050650_create_members.rb +0 -12
  77. data/test/db/migrate/20111012231923_create_posts.rb +0 -12
  78. data/test/db/migrate/20111013050657_create_zines.rb +0 -10
  79. data/test/db/migrate/20111013050753_create_teams.rb +0 -10
  80. data/test/db/migrate/20111013050837_create_team_assets.rb +0 -11
  81. data/test/db/schema.rb +0 -126
  82. data/test/db/seeds.rb +0 -7
  83. data/test/test/controllers/home_controller_test.rb +0 -132
  84. data/test/test/ctlr_test_helper.rb +0 -11
  85. data/test/test/fixtures/members.yml +0 -35
  86. data/test/test/fixtures/posts.yml +0 -96
  87. data/test/test/fixtures/team_assets.yml +0 -30
  88. data/test/test/fixtures/teams.yml +0 -17
  89. data/test/test/fixtures/tenants.yml +0 -12
  90. data/test/test/fixtures/tenants_users.yml +0 -15
  91. data/test/test/fixtures/users.yml +0 -33
  92. data/test/test/fixtures/zines.yml +0 -25
  93. data/test/test/models/member_test.rb +0 -75
  94. data/test/test/models/post_test.rb +0 -66
  95. data/test/test/models/team_test.rb +0 -49
  96. data/test/test/models/tenant_test.rb +0 -228
  97. data/test/test/models/user_test.rb +0 -182
  98. data/test/test/models/zine_test.rb +0 -40
  99. data/test/test/test_helper.rb +0 -31
@@ -1,182 +0,0 @@
1
- require 'test_helper'
2
-
3
- # #############################################################################
4
- # Note: this tests not only the methods in models/user.rb but
5
- # also all of the milia-injected methods from base.rb for
6
- # acts_as_universal_and_determines_account
7
- # #############################################################################
8
-
9
- class UserTest < ActiveSupport::TestCase
10
-
11
- context "a user" do
12
-
13
- # ------------------------------------------------------------------------
14
- # ------------------------------------------------------------------------
15
- setup do
16
- Tenant.set_current_tenant( tenants( :tenant_1 ).id )
17
- @user = users(:quentin)
18
- end
19
-
20
- # ------------------------------------------------------------------------
21
- # ------------------------------------------------------------------------
22
- should have_one( :member )
23
- should have_many( :tenanted_members )
24
- should have_and_belong_to_many( :tenants )
25
- should_not allow_value("wild blue").for(:email)
26
-
27
- should have_db_column(:tenant_id)
28
- should have_db_column(:skip_confirm_change_password).with_options(default: 'f')
29
-
30
- should have_db_index(:email)
31
- should have_db_index(:confirmation_token)
32
- should have_db_index(:reset_password_token)
33
-
34
- should "define the current tenant" do
35
- assert Thread.current[:tenant_id]
36
- end
37
-
38
- should 'have password' do
39
- assert !@user.has_no_password?
40
- end # should do
41
-
42
- should 'not have password' do
43
- assert User.new(email: "billybob@bob.com").has_no_password?
44
- end # should do
45
-
46
- should 'attempt set password' do
47
- assert users(:jermaine).attempt_set_password(
48
- password: 'wild_blue',
49
- password_confirmation: 'wild_blue'
50
- )
51
- end # should do
52
-
53
- should 'check or set password - missing' do
54
- user = User.new(email: "billybob@bob.com")
55
- assert user.has_no_password?
56
- user.check_or_set_password
57
- assert !user.has_no_password?
58
- assert !user.skip_confirm_change_password?
59
- end # should do
60
-
61
- should 'check or set password - present' do
62
- user = User.new(
63
- email: "billybob@bob.com",
64
- password: 'limesublime',
65
- password_confirmation: 'limesublime'
66
- )
67
- assert !user.has_no_password?
68
- user.check_or_set_password
69
- assert user.skip_confirm_change_password?
70
- end # should do
71
-
72
- should 'save and invite member - error no email' do
73
- user = User.new(password: "wildblue")
74
- assert_nil user.save_and_invite_member
75
- assert !user.errors.empty?
76
- end # should do
77
-
78
- should 'save and invite member - error duplicate email' do
79
- user = User.new(email: "jermaine@example.com")
80
- assert_nil user.save_and_invite_member
81
- assert !user.errors.empty?
82
- end # should do
83
-
84
- should 'save and invite member - success' do
85
- user = User.new(email: "limesublime@example.com")
86
- assert user.save_and_invite_member
87
- assert user.errors.empty?
88
- end # should do
89
-
90
- # #############################################################################
91
- # #############################################################################
92
-
93
-
94
- should 'NOT create new user when invalid current tenant - string' do
95
- # force the current_tenant to be unexpected object
96
- Thread.current[:tenant_id] = 'peanut clusters'
97
-
98
- assert_no_difference("User.count") do
99
- assert_raise(::Milia::Control::InvalidTenantAccess,
100
- "no existing valid current tenant") {
101
-
102
- # setup new user
103
- user = User.new(email: "limesublime@example.com")
104
- user.save_and_invite_member
105
- }
106
- end # no difference
107
-
108
- end # should do
109
-
110
- should 'NOT create new user when invalid current tenant - nil' do
111
- # force the current_tenant to be nil
112
- Thread.current[:tenant_id] = nil
113
-
114
- assert_no_difference("User.count") do
115
- assert_raise(::Milia::Control::InvalidTenantAccess,
116
- "no existing valid current tenant") {
117
-
118
- # setup new user
119
- user = User.new(email: "limesublime@example.com")
120
- user.save_and_invite_member
121
- }
122
- end # no difference
123
-
124
- end # should do
125
-
126
- should 'NOT create new user when invalid current tenant - zero' do
127
- # force the current_tenant to be 0
128
- Thread.current[:tenant_id] = 0
129
-
130
- assert_no_difference("User.count") do
131
- assert_raise(::Milia::Control::InvalidTenantAccess,
132
- "no existing valid current tenant") {
133
-
134
- # setup new user
135
- user = User.new(email: "limesublime@example.com")
136
- user.save_and_invite_member
137
- }
138
- end # no difference
139
-
140
- end # should do
141
-
142
- # this validates both the before_create and after_create for users
143
- should 'create new user when valid current tenant' do
144
- tenant = tenants(:tenant_1)
145
- assert_equal 1,tenant.users.count
146
-
147
- assert_difference("User.count") do
148
- assert_nothing_raised(::Milia::Control::InvalidTenantAccess,
149
- "no existing valid current tenant") {
150
-
151
- # setup new user
152
- user = User.new(email: "limesublime@example.com")
153
- user.save_and_invite_member
154
- }
155
- end # no difference
156
-
157
- tenant.reload
158
- assert_equal 2,tenant.users.count
159
-
160
- end # should do
161
-
162
-
163
- should 'destroy a user and clear its tenants habtm' do
164
- tenant = tenants(:tenant_2)
165
- Tenant.set_current_tenant( tenant )
166
- quentin = users(:quentin)
167
- assert_equal 3,tenant.users.count
168
- quentin.destroy
169
- tenant.reload
170
- assert_equal 2,tenant.users.count
171
- end # should do
172
-
173
-
174
-
175
- # ok to create user, member
176
- # @user = User.new( user_params )
177
- # if @user.save_and_invite_member() && @user.create_member( member_params )
178
-
179
-
180
- end # context user
181
-
182
- end # class
@@ -1,40 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZineTest < ActiveSupport::TestCase
4
-
5
- context "a zine" do
6
-
7
- setup do
8
- Tenant.set_current_tenant( tenants( :tenant_2 ).id )
9
- @zine = Zine.first
10
- end
11
-
12
- # validate multi-tenanting structure
13
- should have_db_column(:tenant_id)
14
- should "match the current tenant" do
15
- assert_equal @zine.tenant_id, Thread.current[:tenant_id]
16
- end
17
-
18
- # validate the model
19
- should have_many( :posts )
20
- should belong_to( :team )
21
- should have_many( :members ).through( :posts )
22
-
23
- # validate the particular associations in the model
24
- should 'find members through posts' do
25
- assert_equal 2, zines( :zine_2_b ).members.count
26
- end #should do
27
-
28
- should 'find posts' do
29
- assert_equal 3, zines( :zine_2_a ).posts.count
30
- end #should do
31
-
32
- should 'match a zine with tenant' do
33
- assert_equal 2,zines( :zine_2_a ).tenant_id
34
- end # should do
35
-
36
-
37
-
38
- end # context zine
39
-
40
- end # class ZineTest
@@ -1,31 +0,0 @@
1
- ENV["RAILS_ENV"] ||= "test"
2
-
3
- require File.expand_path('../../config/environment', __FILE__)
4
- require 'rails/test_help'
5
-
6
- class ActiveSupport::TestCase
7
-
8
- ActiveRecord::Migration.check_pending!
9
-
10
- # -----------------------------------------------------------------------------
11
- # any class-level stuff for special handling
12
- # -----------------------------------------------------------------------------
13
- class << self
14
-
15
- end # anon class
16
-
17
- # -----------------------------------------------------------------------------
18
- # -----------------------------------------------------------------------------
19
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
20
- #
21
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
22
- # -- they do not yet inherit this setting
23
- fixtures :all
24
-
25
- # Add more helper methods to be used by all tests here...
26
-
27
- # -----------------------------------------------------------------------------
28
- # -----------------------------------------------------------------------------
29
-
30
- end # class ActiveSupport::TestCase
31
-