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,12 +0,0 @@
1
- class AddSessionsTable < ActiveRecord::Migration
2
- def change
3
- create_table :sessions do |t|
4
- t.string :session_id, :null => false
5
- t.text :data
6
- t.timestamps
7
- end
8
-
9
- add_index :sessions, :session_id, :unique => true
10
- add_index :sessions, :updated_at
11
- end
12
- end
@@ -1,48 +0,0 @@
1
- class DeviseCreateUsers < ActiveRecord::Migration
2
- def change
3
- create_table(:users) do |t|
4
- ## Database authenticatable
5
- t.string :email, :null => false, :default => ""
6
- t.string :encrypted_password, :null => false, :default => ""
7
-
8
- ## Recoverable
9
- t.string :reset_password_token
10
- t.datetime :reset_password_sent_at
11
-
12
- ## Rememberable
13
- t.datetime :remember_created_at
14
-
15
- ## Trackable
16
- t.integer :sign_in_count, :default => 0, :null => false
17
- t.datetime :current_sign_in_at
18
- t.datetime :last_sign_in_at
19
- t.string :current_sign_in_ip
20
- t.string :last_sign_in_ip
21
-
22
- ## Confirmable
23
- t.string :confirmation_token
24
- t.datetime :confirmed_at
25
- t.datetime :confirmation_sent_at
26
- t.string :unconfirmed_email # Only if using reconfirmable
27
-
28
- ## Lockable
29
- # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
30
- # t.string :unlock_token # Only if unlock strategy is :email or :both
31
- # t.datetime :locked_at
32
-
33
- # milia member_invitable
34
- t.boolean :skip_confirm_change_password, :default => false
35
- t.references :tenant
36
- t.string :authentication_token
37
-
38
-
39
- t.timestamps
40
- end
41
-
42
- add_index :users, :email, :unique => true
43
- add_index :users, :reset_password_token, :unique => true
44
- add_index :users, :confirmation_token, :unique => true
45
- add_index :users, :authentication_token, :unique => true
46
- # add_index :users, :unlock_token, :unique => true
47
- end
48
- end
@@ -1,11 +0,0 @@
1
- class CreateTenants < ActiveRecord::Migration
2
- def change
3
- create_table :tenants do |t|
4
- t.references :tenant, index: true
5
- t.string :name
6
-
7
- t.timestamps
8
- end
9
- add_index :tenants, :name
10
- end
11
- end
@@ -1,8 +0,0 @@
1
- class CreateTenantsUsersJoinTable < ActiveRecord::Migration
2
- def change
3
- create_join_table :tenants, :users do |t|
4
- t.index [:tenant_id, :user_id]
5
- # t.index [:user_id, :tenant_id]
6
- end
7
- end
8
- end
@@ -1,12 +0,0 @@
1
- class CreateMembers < ActiveRecord::Migration
2
- def change
3
- create_table :members do |t|
4
- t.references :tenant, index: true
5
- t.references :user, index: true
6
- t.string :first_name
7
- t.string :last_name
8
-
9
- t.timestamps
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- class CreatePosts < ActiveRecord::Migration
2
- def change
3
- create_table :posts do |t|
4
- t.references :tenant, index: true
5
- t.references :member, index: true
6
- t.references :zine, index: true
7
- t.string :content
8
-
9
- t.timestamps
10
- end
11
- end
12
- end
@@ -1,10 +0,0 @@
1
- class CreateZines < ActiveRecord::Migration
2
- def change
3
- create_table :zines do |t|
4
- t.references :tenant, index: true
5
- t.references :team, index: true
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- class CreateTeams < ActiveRecord::Migration
2
- def change
3
- create_table :teams do |t|
4
- t.references :tenant, index: true
5
- t.string :name
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- class CreateTeamAssets < ActiveRecord::Migration
2
- def change
3
- create_table :team_assets do |t|
4
- t.references :tenant, index: true
5
- t.references :member, index: true
6
- t.references :team, index: true
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,126 +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 that you check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(version: 20111013050837) do
15
-
16
- create_table "members", force: true do |t|
17
- t.integer "tenant_id"
18
- t.integer "user_id"
19
- t.string "first_name"
20
- t.string "last_name"
21
- t.datetime "created_at"
22
- t.datetime "updated_at"
23
- end
24
-
25
- add_index "members", ["tenant_id"], name: "index_members_on_tenant_id"
26
- add_index "members", ["user_id"], name: "index_members_on_user_id"
27
-
28
- create_table "posts", force: true do |t|
29
- t.integer "tenant_id"
30
- t.integer "member_id"
31
- t.integer "zine_id"
32
- t.string "content"
33
- t.datetime "created_at"
34
- t.datetime "updated_at"
35
- end
36
-
37
- add_index "posts", ["member_id"], name: "index_posts_on_member_id"
38
- add_index "posts", ["tenant_id"], name: "index_posts_on_tenant_id"
39
- add_index "posts", ["zine_id"], name: "index_posts_on_zine_id"
40
-
41
- create_table "sessions", force: true do |t|
42
- t.string "session_id", null: false
43
- t.text "data"
44
- t.datetime "created_at"
45
- t.datetime "updated_at"
46
- end
47
-
48
- add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", unique: true
49
- add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at"
50
-
51
- create_table "team_assets", force: true do |t|
52
- t.integer "tenant_id"
53
- t.integer "member_id"
54
- t.integer "team_id"
55
- t.datetime "created_at"
56
- t.datetime "updated_at"
57
- end
58
-
59
- add_index "team_assets", ["member_id"], name: "index_team_assets_on_member_id"
60
- add_index "team_assets", ["team_id"], name: "index_team_assets_on_team_id"
61
- add_index "team_assets", ["tenant_id"], name: "index_team_assets_on_tenant_id"
62
-
63
- create_table "teams", force: true do |t|
64
- t.integer "tenant_id"
65
- t.string "name"
66
- t.datetime "created_at"
67
- t.datetime "updated_at"
68
- end
69
-
70
- add_index "teams", ["tenant_id"], name: "index_teams_on_tenant_id"
71
-
72
- create_table "tenants", force: true do |t|
73
- t.integer "tenant_id"
74
- t.string "name"
75
- t.datetime "created_at"
76
- t.datetime "updated_at"
77
- end
78
-
79
- add_index "tenants", ["name"], name: "index_tenants_on_name"
80
- add_index "tenants", ["tenant_id"], name: "index_tenants_on_tenant_id"
81
-
82
- create_table "tenants_users", id: false, force: true do |t|
83
- t.integer "tenant_id", null: false
84
- t.integer "user_id", null: false
85
- end
86
-
87
- add_index "tenants_users", ["tenant_id", "user_id"], name: "index_tenants_users_on_tenant_id_and_user_id"
88
-
89
- create_table "users", force: true do |t|
90
- t.string "email", default: "", null: false
91
- t.string "encrypted_password", default: "", null: false
92
- t.string "reset_password_token"
93
- t.datetime "reset_password_sent_at"
94
- t.datetime "remember_created_at"
95
- t.integer "sign_in_count", default: 0, null: false
96
- t.datetime "current_sign_in_at"
97
- t.datetime "last_sign_in_at"
98
- t.string "current_sign_in_ip"
99
- t.string "last_sign_in_ip"
100
- t.string "confirmation_token"
101
- t.datetime "confirmed_at"
102
- t.datetime "confirmation_sent_at"
103
- t.string "unconfirmed_email"
104
- t.boolean "skip_confirm_change_password", default: false
105
- t.integer "tenant_id"
106
- t.string "authentication_token"
107
- t.datetime "created_at"
108
- t.datetime "updated_at"
109
- end
110
-
111
- add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true
112
- add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
113
- add_index "users", ["email"], name: "index_users_on_email", unique: true
114
- add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
115
-
116
- create_table "zines", force: true do |t|
117
- t.integer "tenant_id"
118
- t.integer "team_id"
119
- t.datetime "created_at"
120
- t.datetime "updated_at"
121
- end
122
-
123
- add_index "zines", ["team_id"], name: "index_zines_on_team_id"
124
- add_index "zines", ["tenant_id"], name: "index_zines_on_tenant_id"
125
-
126
- end
@@ -1,7 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # Examples:
5
- #
6
- # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
- # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -1,132 +0,0 @@
1
- require 'ctlr_test_helper'
2
-
3
- class HomeControllerTest < ActionController::TestCase
4
-
5
- context 'home ctlr' do
6
- setup do
7
- Tenant.set_current_tenant( tenants( :tenant_1 ).id )
8
- end
9
-
10
- should "get index" do
11
- get :index
12
- assert_response :success
13
- end
14
-
15
- should "get show with login" do
16
- sign_in( users( :quentin ) )
17
- get :show
18
- assert_response :success
19
- sign_out( users( :quentin ) )
20
- end # should do
21
-
22
- should 'not get show without login' do
23
- get :show
24
- # redirects to sign in page
25
- assert_redirected_to new_user_session_path
26
- end # should do
27
-
28
- should 'reset tenant' do
29
- assert Tenant.current_tenant_id
30
- @controller.__milia_reset_tenant! # invoke the private method
31
- assert_nil Tenant.current_tenant_id
32
-
33
- end # should do
34
-
35
- should 'change tenant' do
36
- assert_equal 1,Tenant.current_tenant_id
37
- @controller.__milia_change_tenant!(2) # invoke the private method
38
- assert_equal 2,Tenant.current_tenant_id
39
- end # should do
40
-
41
- should 'trace tenanting' do
42
- ::Milia.trace_on = true
43
- @controller.trace_tenanting( "wild blue" )
44
- ::Milia.trace_on = false
45
- @controller.trace_tenanting( "duck walk" )
46
- end # should do
47
-
48
- should 'initiate tenant' do
49
- @controller.initiate_tenant( tenants(:tenant_2) )
50
- assert_equal 2,Tenant.current_tenant_id
51
- end # should do
52
-
53
- should 'redirect back' do
54
- # alter the code to invoke redirect_back
55
- @controller.class.module_eval(
56
- %q{
57
- def index()
58
- redirect_back
59
- end
60
- }
61
- )
62
-
63
- # now test it
64
- get :index
65
- assert_response :redirect
66
- assert_redirected_to root_url()
67
-
68
- end # should do
69
-
70
- should 'prep signup view' do
71
- assert_nil @controller.instance_eval( "@tenant" )
72
- @controller.prep_signup_view(
73
- { name: 'Mangoland' },
74
- {email: 'billybob@bob.com', password: 'monkeymocha', password_confirmation: 'monkeymocha'}
75
- )
76
- assert_equal 'Mangoland', @controller.instance_eval( "@tenant" ).name
77
- end # should do
78
-
79
- should 'handle max_tenants exception' do
80
- # alter the code to invoke redirect_back
81
- @controller.class.module_eval(
82
- %q{
83
- def index()
84
- max_tenants
85
- end
86
- }
87
- )
88
-
89
- # now test it
90
- get :index, { user: { email: 'billybob@bob.com' }, tenant: {name: 'Mangoland'} }
91
- assert_response :redirect
92
- assert_redirected_to root_url()
93
-
94
- end # should do
95
-
96
-
97
- should 'set current tenant - user not signed in' do
98
- assert @controller.set_current_tenant( 2 )
99
- assert_nil Tenant.current_tenant_id
100
- end # should do
101
-
102
-
103
- should 'set current tenant - user signed in; tid not nil; valid for user' do
104
- sign_in( users( :quentin ) )
105
- assert @controller.set_current_tenant( 2 )
106
- assert_equal 2,Tenant.current_tenant_id
107
- end # should do
108
-
109
- should 'set current tenant - user signed in; tid not nil; invalid for user' do
110
- sign_in( users( :quentin ) )
111
- assert_raise(Milia::Control::InvalidTenantAccess){
112
- @controller.set_current_tenant( 3 )
113
- }
114
- assert_equal 1,Tenant.current_tenant_id # should be unchanged
115
- end # should do
116
-
117
-
118
- should 'authenticate tenant - 1' do
119
-
120
- @controller.set_current_tenant( )
121
- sign_in( users( :quentin ) )
122
- @controller.authenticate_tenant!
123
- assert_response :success
124
- assert_equal 1,Tenant.current_tenant_id
125
-
126
- end # should do
127
-
128
-
129
-
130
- end # context
131
-
132
- end # end class test
@@ -1,11 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ActiveSupport::TestCase
4
-
5
- end
6
-
7
-
8
- class ActionController::TestCase
9
- include Devise::TestHelpers
10
-
11
- end # class
@@ -1,35 +0,0 @@
1
- quentin_1:
2
- tenant_id: 1
3
- user_id: 1
4
- first_name: Quentin
5
- last_name: Brown
6
- created_at: <%= 5.days.ago.to_s :db %>
7
-
8
- quentin_2:
9
- tenant_id: 2
10
- user_id: 1
11
- first_name: Quentin2
12
- last_name: Brown2
13
- created_at: <%= 5.days.ago.to_s :db %>
14
-
15
- demarcus_2:
16
- tenant_id: 2
17
- user_id: 2
18
- first_name: Admin
19
- last_name: Please edit me
20
- created_at: <%= 1.days.ago.to_s :db %>
21
-
22
- jermaine_2:
23
- tenant_id: 2
24
- user_id: 3
25
- first_name: Jermaine2
26
- last_name: Potts2
27
- created_at: <%= 5.days.ago.to_s :db %>
28
-
29
- jermaine_3:
30
- tenant_id: 3
31
- user_id: 3
32
- first_name: Jermaine
33
- last_name: Potts
34
- created_at: <%= 5.days.ago.to_s :db %>
35
-