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.
- checksums.yaml +4 -4
- data/app/controllers/confirmations_controller.rb +7 -7
- data/app/controllers/registrations_controller.rb +13 -19
- data/app/views/devise/registrations/new.html.haml +53 -0
- data/lib/generators/milia/install_generator.rb +44 -41
- data/lib/generators/milia/templates/devise_permitted_parameters.rb +18 -0
- data/lib/generators/milia/templates/initializer.rb +3 -9
- data/lib/milia.rb +3 -22
- data/lib/milia/base.rb +88 -109
- data/lib/milia/control.rb +25 -25
- data/lib/milia/invite_member.rb +6 -6
- data/lib/milia/version.rb +1 -1
- metadata +16 -184
- data/.document +0 -5
- data/.gitignore +0 -94
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.slugignore +0 -2
- data/.travis.yml +0 -4
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -20
- data/README.md +0 -1207
- data/Rakefile +0 -1
- data/doc/gemfile_addition.txt +0 -28
- data/doc/manual_sample.sh +0 -816
- data/doc/ref_notes.txt +0 -155
- data/doc/sample.sh +0 -276
- data/markdown.rb +0 -38
- data/milia.gemspec +0 -29
- data/test/.ruby-gemset +0 -1
- data/test/.ruby-version +0 -1
- data/test/Gemfile +0 -81
- data/test/Gemfile.lock +0 -223
- data/test/README.md +0 -83
- data/test/Rakefile +0 -6
- data/test/app/assets/javascripts/application.js +0 -16
- data/test/app/assets/stylesheets/application.css +0 -13
- data/test/app/controllers/application_controller.rb +0 -13
- data/test/app/controllers/home_controller.rb +0 -10
- data/test/app/helpers/application_helper.rb +0 -2
- data/test/app/models/member.rb +0 -34
- data/test/app/models/post.rb +0 -14
- data/test/app/models/team.rb +0 -9
- data/test/app/models/team_asset.rb +0 -6
- data/test/app/models/tenant.rb +0 -54
- data/test/app/models/user.rb +0 -14
- data/test/app/models/zine.rb +0 -8
- data/test/app/views/home/index.html.erb +0 -2
- data/test/app/views/home/show.html.erb +0 -2
- data/test/app/views/layouts/application.html.erb +0 -14
- data/test/bin/bundle +0 -3
- data/test/bin/rails +0 -4
- data/test/bin/rake +0 -4
- data/test/config/application.rb +0 -36
- data/test/config/boot.rb +0 -4
- data/test/config/database.yml +0 -25
- data/test/config/environment.rb +0 -5
- data/test/config/environments/development.rb +0 -48
- data/test/config/environments/production.rb +0 -95
- data/test/config/environments/test.rb +0 -42
- data/test/config/initializers/backtrace_silencers.rb +0 -7
- data/test/config/initializers/devise.rb +0 -254
- data/test/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/config/initializers/inflections.rb +0 -16
- data/test/config/initializers/milia.rb +0 -51
- data/test/config/initializers/mime_types.rb +0 -5
- data/test/config/initializers/secret_token.rb +0 -12
- data/test/config/initializers/session_store.rb +0 -3
- data/test/config/initializers/wrap_parameters.rb +0 -14
- data/test/config/locales/en.yml +0 -23
- data/test/config/routes.rb +0 -77
- data/test/db/migrate/20111012050200_add_sessions_table.rb +0 -12
- data/test/db/migrate/20111012050340_devise_create_users.rb +0 -48
- data/test/db/migrate/20111012050532_create_tenants.rb +0 -11
- data/test/db/migrate/20111012050600_create_tenants_users_join_table.rb +0 -8
- data/test/db/migrate/20111012050650_create_members.rb +0 -12
- data/test/db/migrate/20111012231923_create_posts.rb +0 -12
- data/test/db/migrate/20111013050657_create_zines.rb +0 -10
- data/test/db/migrate/20111013050753_create_teams.rb +0 -10
- data/test/db/migrate/20111013050837_create_team_assets.rb +0 -11
- data/test/db/schema.rb +0 -126
- data/test/db/seeds.rb +0 -7
- data/test/test/controllers/home_controller_test.rb +0 -132
- data/test/test/ctlr_test_helper.rb +0 -11
- data/test/test/fixtures/members.yml +0 -35
- data/test/test/fixtures/posts.yml +0 -96
- data/test/test/fixtures/team_assets.yml +0 -30
- data/test/test/fixtures/teams.yml +0 -17
- data/test/test/fixtures/tenants.yml +0 -12
- data/test/test/fixtures/tenants_users.yml +0 -15
- data/test/test/fixtures/users.yml +0 -33
- data/test/test/fixtures/zines.yml +0 -25
- data/test/test/models/member_test.rb +0 -75
- data/test/test/models/post_test.rb +0 -66
- data/test/test/models/team_test.rb +0 -49
- data/test/test/models/tenant_test.rb +0 -228
- data/test/test/models/user_test.rb +0 -182
- data/test/test/models/zine_test.rb +0 -40
- 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
|
data/test/test/test_helper.rb
DELETED
@@ -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
|
-
|