milia 0.3.38 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +94 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -16
- data/README.md +890 -141
- data/Rakefile +1 -55
- data/app/controllers/confirmations_controller.rb +101 -0
- data/app/controllers/passwords_controller.rb +8 -0
- data/app/controllers/registrations_controller.rb +95 -25
- data/app/controllers/sessions_controller.rb +13 -0
- data/app/views/members/new.html.haml +33 -0
- data/doc/gemfile_addition.txt +28 -0
- data/doc/manual_sample.sh +816 -0
- data/doc/sample.sh +229 -0
- data/lib/generators/milia/install_generator.rb +546 -0
- data/lib/generators/milia/temp_generator.rb +93 -0
- data/lib/generators/milia/templates/initializer.rb +51 -0
- data/lib/milia.rb +89 -1
- data/lib/milia/base.rb +29 -4
- data/lib/milia/control.rb +161 -9
- data/lib/milia/invite_member.rb +92 -0
- data/lib/milia/password_generator.rb +171 -0
- data/lib/milia/railtie.rb +4 -1
- data/lib/milia/version.rb +3 -0
- data/milia.gemspec +24 -159
- data/test/.ruby-gemset +1 -0
- data/test/.ruby-version +1 -0
- data/test/Gemfile +81 -0
- data/test/Gemfile.lock +200 -0
- data/test/README.md +83 -0
- data/test/{rails_app/Rakefile → Rakefile} +1 -2
- data/test/app/assets/javascripts/application.js +16 -0
- data/test/app/assets/stylesheets/application.css +13 -0
- data/test/app/controllers/application_controller.rb +13 -0
- data/test/app/controllers/home_controller.rb +10 -0
- data/test/{rails_app/app → app}/helpers/application_helper.rb +0 -0
- data/test/app/models/member.rb +34 -0
- data/test/app/models/post.rb +14 -0
- data/test/{rails_app/app → app}/models/team.rb +3 -2
- data/test/{rails_app/app → app}/models/team_asset.rb +1 -1
- data/test/app/models/tenant.rb +54 -0
- data/test/app/models/user.rb +14 -0
- data/test/app/models/zine.rb +8 -0
- data/test/{rails_app/app → app}/views/home/index.html.erb +0 -0
- data/test/app/views/home/show.html.erb +2 -0
- data/test/app/views/layouts/application.html.erb +14 -0
- data/test/bin/bundle +3 -0
- data/test/bin/rails +4 -0
- data/test/bin/rake +4 -0
- data/test/config/application.rb +36 -0
- data/test/{rails_app/config → config}/boot.rb +0 -2
- data/test/config/database.yml +25 -0
- data/test/config/environment.rb +5 -0
- data/test/config/environments/development.rb +48 -0
- data/test/config/environments/production.rb +95 -0
- data/test/config/environments/test.rb +42 -0
- data/test/{rails_app/config → config}/initializers/backtrace_silencers.rb +0 -0
- data/test/{rails_app/config → config}/initializers/devise.rb +84 -36
- data/test/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/config/initializers/inflections.rb +16 -0
- data/test/config/initializers/milia.rb +51 -0
- data/test/{rails_app/config → config}/initializers/mime_types.rb +0 -0
- data/test/config/initializers/secret_token.rb +12 -0
- data/test/config/initializers/session_store.rb +3 -0
- data/test/{rails_app/config → config}/initializers/wrap_parameters.rb +6 -6
- data/test/config/locales/en.yml +23 -0
- data/test/config/routes.rb +77 -0
- data/test/{rails_app/db/migrate/20111012060818_add_sessions_table.rb → db/migrate/20111012050200_add_sessions_table.rb} +2 -6
- data/test/db/migrate/20111012050340_devise_create_users.rb +48 -0
- data/test/{rails_app/db → db}/migrate/20111012050532_create_tenants.rb +3 -1
- data/test/db/migrate/20111012050600_create_tenants_users_join_table.rb +8 -0
- data/test/db/migrate/20111012050650_create_members.rb +12 -0
- data/test/db/migrate/20111012231923_create_posts.rb +12 -0
- data/test/{rails_app/db → db}/migrate/20111013050657_create_zines.rb +2 -4
- data/test/{rails_app/db → db}/migrate/20111013050753_create_teams.rb +1 -2
- data/test/db/migrate/20111013050837_create_team_assets.rb +11 -0
- data/test/db/schema.rb +126 -0
- data/test/{rails_app/db → db}/seeds.rb +0 -0
- data/test/test/controllers/home_controller_test.rb +133 -0
- data/test/{rails_app/test → test}/ctlr_test_helper.rb +0 -0
- data/test/test/fixtures/members.yml +35 -0
- data/test/test/fixtures/posts.yml +96 -0
- data/test/test/fixtures/team_assets.yml +30 -0
- data/test/test/fixtures/teams.yml +17 -0
- data/test/test/fixtures/tenants.yml +12 -0
- data/test/test/fixtures/tenants_users.yml +15 -0
- data/test/test/fixtures/users.yml +33 -0
- data/test/test/fixtures/zines.yml +25 -0
- data/test/test/models/member_test.rb +75 -0
- data/test/test/models/post_test.rb +66 -0
- data/test/test/models/team_test.rb +49 -0
- data/test/test/models/tenant_test.rb +228 -0
- data/test/test/models/user_test.rb +182 -0
- data/test/test/models/zine_test.rb +40 -0
- data/test/test/test_helper.rb +31 -0
- metadata +199 -154
- data/.rvmrc +0 -1
- data/Gemfile.lock +0 -115
- data/VERSION +0 -1
- data/test/helper.rb +0 -18
- data/test/rails_app/.gitignore +0 -5
- data/test/rails_app/Gemfile +0 -48
- data/test/rails_app/Gemfile.lock +0 -168
- data/test/rails_app/Gemfile.lock.backup +0 -167
- data/test/rails_app/Procfile +0 -1
- data/test/rails_app/README +0 -261
- data/test/rails_app/app/assets/images/rails.png +0 -0
- data/test/rails_app/app/assets/javascripts/application.js +0 -9
- data/test/rails_app/app/assets/javascripts/home.js.coffee +0 -3
- data/test/rails_app/app/assets/stylesheets/application.css +0 -7
- data/test/rails_app/app/assets/stylesheets/home.css.scss +0 -3
- data/test/rails_app/app/controllers/application_controller.rb +0 -50
- data/test/rails_app/app/controllers/home_controller.rb +0 -7
- data/test/rails_app/app/helpers/home_helper.rb +0 -2
- data/test/rails_app/app/mailers/.gitkeep +0 -0
- data/test/rails_app/app/models/.gitkeep +0 -0
- data/test/rails_app/app/models/author.rb +0 -9
- data/test/rails_app/app/models/calendar.rb +0 -6
- data/test/rails_app/app/models/post.rb +0 -15
- data/test/rails_app/app/models/tenant.rb +0 -8
- data/test/rails_app/app/models/user.rb +0 -14
- data/test/rails_app/app/models/zine.rb +0 -6
- data/test/rails_app/app/views/layouts/application.html.erb +0 -12
- data/test/rails_app/config.ru +0 -4
- data/test/rails_app/config/application.rb +0 -56
- data/test/rails_app/config/database.yml +0 -55
- data/test/rails_app/config/environment.rb +0 -5
- data/test/rails_app/config/environments/development.rb +0 -41
- data/test/rails_app/config/environments/production.rb +0 -60
- data/test/rails_app/config/environments/test.rb +0 -56
- data/test/rails_app/config/initializers/inflections.rb +0 -10
- data/test/rails_app/config/initializers/secret_token.rb +0 -7
- data/test/rails_app/config/initializers/session_store.rb +0 -8
- data/test/rails_app/config/locales/devise.en.yml +0 -58
- data/test/rails_app/config/locales/en.yml +0 -5
- data/test/rails_app/config/routes.rb +0 -63
- data/test/rails_app/db/migrate/20111012050340_devise_create_users.rb +0 -39
- data/test/rails_app/db/migrate/20111012050600_create_tenants_users.rb +0 -10
- data/test/rails_app/db/migrate/20111012231923_create_posts.rb +0 -15
- data/test/rails_app/db/migrate/20111013050558_create_calendars.rb +0 -14
- data/test/rails_app/db/migrate/20111013050837_create_team_assets.rb +0 -14
- data/test/rails_app/db/migrate/20111013053403_create_authors.rb +0 -13
- data/test/rails_app/db/schema.rb +0 -133
- data/test/rails_app/lib/assets/.gitkeep +0 -0
- data/test/rails_app/lib/tasks/.gitkeep +0 -0
- data/test/rails_app/log/.gitkeep +0 -0
- data/test/rails_app/public/404.html +0 -26
- data/test/rails_app/public/422.html +0 -26
- data/test/rails_app/public/500.html +0 -26
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/script/rails +0 -6
- data/test/rails_app/test/factories/units_factory.rb +0 -84
- data/test/rails_app/test/fixtures/.gitkeep +0 -0
- data/test/rails_app/test/functional/.gitkeep +0 -0
- data/test/rails_app/test/functional/home_controller_test.rb +0 -10
- data/test/rails_app/test/integration/.gitkeep +0 -0
- data/test/rails_app/test/performance/browsing_test.rb +0 -12
- data/test/rails_app/test/test_helper.rb +0 -119
- data/test/rails_app/test/unit/.gitkeep +0 -0
- data/test/rails_app/test/unit/author_test.rb +0 -30
- data/test/rails_app/test/unit/calendar_test.rb +0 -28
- data/test/rails_app/test/unit/helpers/home_helper_test.rb +0 -7
- data/test/rails_app/test/unit/post_test.rb +0 -81
- data/test/rails_app/test/unit/team_test.rb +0 -30
- data/test/rails_app/test/unit/tenant_test.rb +0 -28
- data/test/rails_app/test/unit/user_test.rb +0 -26
- data/test/rails_app/test/unit/zine_test.rb +0 -28
- data/test/rails_app/vendor/assets/stylesheets/.gitkeep +0 -0
- data/test/rails_app/vendor/plugins/.gitkeep +0 -0
- data/test/rails_app/vendor/plugins/rails_log_stdout/init.rb +0 -43
- data/test/test_milia.rb +0 -7
@@ -1,15 +0,0 @@
|
|
1
|
-
class CreatePosts < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :posts do |t|
|
4
|
-
t.references :tenant
|
5
|
-
t.references :author
|
6
|
-
t.references :zine
|
7
|
-
t.string :content
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
add_index :posts, :tenant_id
|
12
|
-
add_index :posts, :author_id
|
13
|
-
add_index :posts, :zine_id
|
14
|
-
end
|
15
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class CreateCalendars < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :calendars do |t|
|
4
|
-
t.references :tenant
|
5
|
-
t.references :team
|
6
|
-
t.datetime :cal_start
|
7
|
-
t.datetime :cal_end
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
add_index :calendars, :tenant_id
|
12
|
-
add_index :calendars, :team_id
|
13
|
-
end
|
14
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class CreateTeamAssets < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :team_assets do |t|
|
4
|
-
t.references :tenant
|
5
|
-
t.references :author
|
6
|
-
t.references :team
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
add_index :team_assets, :tenant_id
|
11
|
-
add_index :team_assets, :author_id
|
12
|
-
add_index :team_assets, :team_id
|
13
|
-
end
|
14
|
-
end
|
data/test/rails_app/db/schema.rb
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# This file is auto-generated from the current state of the database. Instead
|
3
|
-
# of editing this file, please use the migrations feature of Active Record to
|
4
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
-
#
|
6
|
-
# Note that this schema.rb definition is the authoritative source for your
|
7
|
-
# database schema. If you need to create the application database on another
|
8
|
-
# system, you should be using db:schema:load, not running all the migrations
|
9
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
-
#
|
12
|
-
# It's strongly recommended to check this file into your version control system.
|
13
|
-
|
14
|
-
ActiveRecord::Schema.define(:version => 20111013053403) do
|
15
|
-
|
16
|
-
create_table "authors", :force => true do |t|
|
17
|
-
t.integer "tenant_id"
|
18
|
-
t.integer "user_id"
|
19
|
-
t.string "name"
|
20
|
-
t.datetime "created_at", :null => false
|
21
|
-
t.datetime "updated_at", :null => false
|
22
|
-
end
|
23
|
-
|
24
|
-
add_index "authors", ["tenant_id"], :name => "index_authors_on_tenant_id"
|
25
|
-
add_index "authors", ["user_id"], :name => "index_authors_on_user_id"
|
26
|
-
|
27
|
-
create_table "calendars", :force => true do |t|
|
28
|
-
t.integer "tenant_id"
|
29
|
-
t.integer "team_id"
|
30
|
-
t.datetime "cal_start"
|
31
|
-
t.datetime "cal_end"
|
32
|
-
t.datetime "created_at", :null => false
|
33
|
-
t.datetime "updated_at", :null => false
|
34
|
-
end
|
35
|
-
|
36
|
-
add_index "calendars", ["team_id"], :name => "index_calendars_on_team_id"
|
37
|
-
add_index "calendars", ["tenant_id"], :name => "index_calendars_on_tenant_id"
|
38
|
-
|
39
|
-
create_table "posts", :force => true do |t|
|
40
|
-
t.integer "tenant_id"
|
41
|
-
t.integer "author_id"
|
42
|
-
t.integer "zine_id"
|
43
|
-
t.string "content"
|
44
|
-
t.datetime "created_at", :null => false
|
45
|
-
t.datetime "updated_at", :null => false
|
46
|
-
end
|
47
|
-
|
48
|
-
add_index "posts", ["author_id"], :name => "index_posts_on_author_id"
|
49
|
-
add_index "posts", ["tenant_id"], :name => "index_posts_on_tenant_id"
|
50
|
-
add_index "posts", ["zine_id"], :name => "index_posts_on_zine_id"
|
51
|
-
|
52
|
-
create_table "sessions", :force => true do |t|
|
53
|
-
t.string "session_id", :null => false
|
54
|
-
t.text "data"
|
55
|
-
t.datetime "created_at", :null => false
|
56
|
-
t.datetime "updated_at", :null => false
|
57
|
-
end
|
58
|
-
|
59
|
-
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
|
60
|
-
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
|
61
|
-
|
62
|
-
create_table "team_assets", :force => true do |t|
|
63
|
-
t.integer "tenant_id"
|
64
|
-
t.integer "author_id"
|
65
|
-
t.integer "team_id"
|
66
|
-
t.datetime "created_at", :null => false
|
67
|
-
t.datetime "updated_at", :null => false
|
68
|
-
end
|
69
|
-
|
70
|
-
add_index "team_assets", ["author_id"], :name => "index_team_assets_on_author_id"
|
71
|
-
add_index "team_assets", ["team_id"], :name => "index_team_assets_on_team_id"
|
72
|
-
add_index "team_assets", ["tenant_id"], :name => "index_team_assets_on_tenant_id"
|
73
|
-
|
74
|
-
create_table "teams", :force => true do |t|
|
75
|
-
t.integer "tenant_id"
|
76
|
-
t.string "name"
|
77
|
-
t.datetime "created_at", :null => false
|
78
|
-
t.datetime "updated_at", :null => false
|
79
|
-
end
|
80
|
-
|
81
|
-
add_index "teams", ["tenant_id"], :name => "index_teams_on_tenant_id"
|
82
|
-
|
83
|
-
create_table "tenants", :force => true do |t|
|
84
|
-
t.integer "tenant_id"
|
85
|
-
t.datetime "created_at", :null => false
|
86
|
-
t.datetime "updated_at", :null => false
|
87
|
-
end
|
88
|
-
|
89
|
-
create_table "tenants_users", :id => false, :force => true do |t|
|
90
|
-
t.integer "tenant_id"
|
91
|
-
t.integer "user_id"
|
92
|
-
end
|
93
|
-
|
94
|
-
add_index "tenants_users", ["tenant_id"], :name => "index_tenants_users_on_tenant_id"
|
95
|
-
add_index "tenants_users", ["user_id"], :name => "index_tenants_users_on_user_id"
|
96
|
-
|
97
|
-
create_table "users", :force => true do |t|
|
98
|
-
t.string "email", :default => "", :null => false
|
99
|
-
t.string "encrypted_password", :default => "", :null => false
|
100
|
-
t.string "reset_password_token"
|
101
|
-
t.datetime "reset_password_sent_at"
|
102
|
-
t.datetime "remember_created_at"
|
103
|
-
t.integer "sign_in_count", :default => 0
|
104
|
-
t.datetime "current_sign_in_at"
|
105
|
-
t.datetime "last_sign_in_at"
|
106
|
-
t.string "current_sign_in_ip"
|
107
|
-
t.string "last_sign_in_ip"
|
108
|
-
t.string "confirmation_token"
|
109
|
-
t.datetime "confirmed_at"
|
110
|
-
t.datetime "confirmation_sent_at"
|
111
|
-
t.string "unconfirmed_email"
|
112
|
-
t.string "authentication_token"
|
113
|
-
t.integer "tenant_id"
|
114
|
-
t.datetime "created_at", :null => false
|
115
|
-
t.datetime "updated_at", :null => false
|
116
|
-
end
|
117
|
-
|
118
|
-
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true
|
119
|
-
add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
|
120
|
-
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
121
|
-
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
122
|
-
|
123
|
-
create_table "zines", :force => true do |t|
|
124
|
-
t.integer "tenant_id"
|
125
|
-
t.integer "calendar_id"
|
126
|
-
t.datetime "created_at", :null => false
|
127
|
-
t.datetime "updated_at", :null => false
|
128
|
-
end
|
129
|
-
|
130
|
-
add_index "zines", ["calendar_id"], :name => "index_zines_on_calendar_id"
|
131
|
-
add_index "zines", ["tenant_id"], :name => "index_zines_on_tenant_id"
|
132
|
-
|
133
|
-
end
|
File without changes
|
File without changes
|
data/test/rails_app/log/.gitkeep
DELETED
File without changes
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/404.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/422.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/500.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
23
|
-
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
File without changes
|
data/test/rails_app/script/rails
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
6
|
-
require 'rails/commands'
|
@@ -1,84 +0,0 @@
|
|
1
|
-
FactoryGirl.define do |binding|
|
2
|
-
|
3
|
-
Thread.current[:tenant_id] = nil # reset at start
|
4
|
-
|
5
|
-
# #############################################################################
|
6
|
-
# ************* HELPER METHODS FOR THIS FACTORY *******************************
|
7
|
-
# #############################################################################
|
8
|
-
class << binding
|
9
|
-
|
10
|
-
# current_tenant -- create or work within a default tenant
|
11
|
-
def current_tenant()
|
12
|
-
Thread.current[:tenant_id] ||= Factory(:tenant).id
|
13
|
-
end
|
14
|
-
|
15
|
-
# new_tenant -- switch over to a new tenant to be the default tenant
|
16
|
-
def new_tenant()
|
17
|
-
Thread.current[:tenant_id] = Factory(:tenant).id
|
18
|
-
end
|
19
|
-
|
20
|
-
USERNAMES = %w(demarcus deshaun jemell jermaine jabari kwashaun musa nigel kissamu yona brenden terell treven tyrese adonys)
|
21
|
-
|
22
|
-
# pick_name -- construct a unique user name based on sequence & world
|
23
|
-
def pick_name(n,w)
|
24
|
-
return USERNAMES[ (n % USERNAMES.size) ] + n.to_s + "_w#{w.to_s}"
|
25
|
-
end
|
26
|
-
|
27
|
-
end # anon class extensions
|
28
|
-
# #############################################################################
|
29
|
-
# #############################################################################
|
30
|
-
|
31
|
-
|
32
|
-
factory :tenant do |f|
|
33
|
-
f.tenant_id nil
|
34
|
-
end
|
35
|
-
|
36
|
-
factory :user do |f|
|
37
|
-
w = binding.current_tenant # establish a current tenant for this duration
|
38
|
-
f.tenant_id nil
|
39
|
-
f.sequence( :email ) { |n| "#{binding.pick_name(n,w)}@example.com" }
|
40
|
-
f.password 'MonkeyMocha'
|
41
|
-
f.password_confirmation { |u| u.password }
|
42
|
-
end # user
|
43
|
-
|
44
|
-
factory :author do |f|
|
45
|
-
w = binding.current_tenant
|
46
|
-
f.tenant_id w
|
47
|
-
f.sequence( :name ) { |n| "#{binding.pick_name(n,w)}@example.com" }
|
48
|
-
f.association :user
|
49
|
-
end # :author
|
50
|
-
|
51
|
-
factory :calendar do |f|
|
52
|
-
f.tenant_id binding.current_tenant
|
53
|
-
f.association :team
|
54
|
-
f.cal_start Time.now.at_beginning_of_month
|
55
|
-
f.cal_end Time.now.at_end_of_month
|
56
|
-
end # calendar
|
57
|
-
|
58
|
-
factory :team do |f|
|
59
|
-
f.tenant_id binding.current_tenant
|
60
|
-
f.sequence( :name ) { |n| "team_#{n}" }
|
61
|
-
f.after_create {|team| f.team_assets = 3.times{ Factory(:team_asset, :team => team) } }
|
62
|
-
end # team
|
63
|
-
|
64
|
-
factory :team_asset do |f|
|
65
|
-
f.tenant_id binding.current_tenant
|
66
|
-
f.association :team
|
67
|
-
f.association :author
|
68
|
-
end
|
69
|
-
|
70
|
-
factory :zine do |f|
|
71
|
-
f.tenant_id binding.current_tenant
|
72
|
-
f.association :calendar
|
73
|
-
end
|
74
|
-
|
75
|
-
CONTENT = %w(wild_blue passion_pink mellow_yellow)
|
76
|
-
|
77
|
-
factory :post do |f|
|
78
|
-
f.tenant_id binding.current_tenant
|
79
|
-
f.sequence( :content ) {|n| CONTENT[n % 3] + "_#{n}" }
|
80
|
-
f.association :author
|
81
|
-
f.association :zine
|
82
|
-
end
|
83
|
-
|
84
|
-
end # FactoryGirl.define
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'rails/performance_test_help'
|
3
|
-
|
4
|
-
class BrowsingTest < ActionDispatch::PerformanceTest
|
5
|
-
# Refer to the documentation for all available options
|
6
|
-
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
|
7
|
-
# :output => 'tmp/performance', :formats => [:flat] }
|
8
|
-
|
9
|
-
def test_homepage
|
10
|
-
get '/'
|
11
|
-
end
|
12
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
2
|
-
require File.expand_path('../../config/environment', __FILE__)
|
3
|
-
require 'rails/test_help'
|
4
|
-
|
5
|
-
class ActiveSupport::TestCase
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
def set_tenant( tenant )
|
10
|
-
Thread.current[:tenant_id] = tenant.id
|
11
|
-
end
|
12
|
-
|
13
|
-
def current_tenant()
|
14
|
-
return Thread.current[:tenant_id]
|
15
|
-
end
|
16
|
-
|
17
|
-
def reset_tenant()
|
18
|
-
Thread.current[:tenant_id] = nil # starting point; no tenant
|
19
|
-
end
|
20
|
-
|
21
|
-
def void_tenant()
|
22
|
-
Thread.current[:tenant_id] = 0 # an impossible tenant
|
23
|
-
end
|
24
|
-
|
25
|
-
end # anon class
|
26
|
-
|
27
|
-
# -----------------------------------------------------------------------------
|
28
|
-
# setup_world -- sets up test rig for three tenants, multiple users, authors, etc
|
29
|
-
# -----------------------------------------------------------------------------
|
30
|
-
def setup_world()
|
31
|
-
@Q1 = DateTime.new(2011,1,1,0,0,0)
|
32
|
-
@Q1end = DateTime.new(2011,3,31,23,59,59)
|
33
|
-
|
34
|
-
@Q2 = DateTime.new(2011,4,1,0,0,0)
|
35
|
-
@Q2end = DateTime.new(2011,6,30,23,59,59)
|
36
|
-
|
37
|
-
@Q3 = DateTime.new(2011,7,1,0,0,0)
|
38
|
-
@Q3end = DateTime.new(2011,9,30,23,59,59)
|
39
|
-
|
40
|
-
@Q4 = DateTime.new(2011,10,1,0,0,0)
|
41
|
-
@Q4end = DateTime.new(2011,12,31,23,59,59)
|
42
|
-
|
43
|
-
@max_worlds = 3
|
44
|
-
@max_teams = 2
|
45
|
-
@max_users = 3
|
46
|
-
|
47
|
-
@dates = [
|
48
|
-
[ @Q1, @Q1end],
|
49
|
-
[ @Q2, @Q2end],
|
50
|
-
[ @Q3, @Q3end],
|
51
|
-
[ @Q4, @Q4end],
|
52
|
-
]
|
53
|
-
|
54
|
-
|
55
|
-
# we'll name objects for each of three worlds to be created
|
56
|
-
@worlds = [ ]
|
57
|
-
|
58
|
-
@max_worlds.times do |w|
|
59
|
-
@teams = []
|
60
|
-
@cals = []
|
61
|
-
@zines = []
|
62
|
-
|
63
|
-
world = Factory(:tenant)
|
64
|
-
@worlds << world
|
65
|
-
ActiveSupport::TestCase.set_tenant( world ) # set the tenant
|
66
|
-
|
67
|
-
@max_teams.times do |i|
|
68
|
-
team = Factory(:team)
|
69
|
-
@teams << team
|
70
|
-
|
71
|
-
cal = Factory(:calendar, :team => team, :cal_start => @dates[i % @dates.size][0], :cal_end => @dates[i % @dates.size][1])
|
72
|
-
@cals << cal
|
73
|
-
|
74
|
-
@zines << Factory(:zine, :calendar => cal)
|
75
|
-
|
76
|
-
end # calendars, teams, zines
|
77
|
-
|
78
|
-
|
79
|
-
@max_users.times do |i|
|
80
|
-
user = Factory(:user)
|
81
|
-
|
82
|
-
if (w.zero? && i == 2) # special case for multiple tenants
|
83
|
-
@target = user # jemell will be in two different tenants
|
84
|
-
setup_author_posts(@target,1,1)
|
85
|
-
end
|
86
|
-
|
87
|
-
# create extra authors w/o associated user
|
88
|
-
@max_teams.times do |j|
|
89
|
-
setup_author_posts(user,i,j)
|
90
|
-
user = nil
|
91
|
-
end
|
92
|
-
|
93
|
-
end # users, authors, posts
|
94
|
-
|
95
|
-
# pick a user and put in multiple tenants
|
96
|
-
if (!@target.nil? && w == 2) # last world
|
97
|
-
world.users << @target # add to current tenant users
|
98
|
-
setup_author_posts(@target,0,0)
|
99
|
-
end
|
100
|
-
|
101
|
-
end # setup each world
|
102
|
-
|
103
|
-
@mangoland = @worlds[0]
|
104
|
-
@limesublime = @worlds[1]
|
105
|
-
@islesmile = @worlds[2]
|
106
|
-
|
107
|
-
end # setup world for testing
|
108
|
-
# -----------------------------------------------------------------------------
|
109
|
-
# -----------------------------------------------------------------------------
|
110
|
-
|
111
|
-
protected
|
112
|
-
def setup_author_posts(user,i,j)
|
113
|
-
author = Factory(:author, :user => user)
|
114
|
-
Factory(:team_asset, :author => author, :team => @teams[i % @max_teams])
|
115
|
-
Factory(:post, :zine => @zines[j], :author => author)
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
end # class ActiveSupport::TestCase
|