milia 0.3.2 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/Gemfile +0 -1
  2. data/Gemfile.lock +7 -9
  3. data/README.rdoc +18 -7
  4. data/VERSION +1 -1
  5. data/lib/milia/base.rb +24 -0
  6. data/lib/milia/control.rb +10 -3
  7. data/milia.gemspec +22 -7
  8. data/test/rails_app/Gemfile +4 -0
  9. data/test/rails_app/Gemfile.lock +25 -12
  10. data/test/rails_app/app/controllers/application_controller.rb +15 -0
  11. data/test/rails_app/app/models/author.rb +9 -0
  12. data/test/rails_app/app/models/calendar.rb +6 -0
  13. data/test/rails_app/app/models/post.rb +15 -0
  14. data/test/rails_app/app/models/team.rb +8 -0
  15. data/test/rails_app/app/models/team_asset.rb +6 -0
  16. data/test/rails_app/app/models/user.rb +2 -0
  17. data/test/rails_app/app/models/zine.rb +6 -0
  18. data/test/rails_app/config/environments/development.rb +5 -0
  19. data/test/rails_app/config/environments/test.rb +17 -0
  20. data/test/rails_app/db/migrate/20111012231923_create_posts.rb +15 -0
  21. data/test/rails_app/db/migrate/20111013050558_create_calendars.rb +14 -0
  22. data/test/rails_app/db/migrate/20111013050657_create_zines.rb +12 -0
  23. data/test/rails_app/db/migrate/20111013050753_create_teams.rb +11 -0
  24. data/test/rails_app/db/migrate/20111013050837_create_team_assets.rb +14 -0
  25. data/test/rails_app/db/migrate/20111013053403_create_authors.rb +13 -0
  26. data/test/rails_app/db/schema.rb +68 -1
  27. data/test/rails_app/script/rails +0 -0
  28. data/test/rails_app/test/ctlr_test_helper.rb +8 -0
  29. data/test/rails_app/test/factories/units_factory.rb +84 -0
  30. data/test/rails_app/test/functional/home_controller_test.rb +1 -1
  31. data/test/rails_app/test/test_helper.rb +116 -8
  32. data/test/rails_app/test/unit/author_test.rb +30 -0
  33. data/test/rails_app/test/unit/calendar_test.rb +28 -0
  34. data/test/rails_app/test/unit/helpers/home_helper_test.rb +3 -0
  35. data/test/rails_app/test/unit/post_test.rb +62 -0
  36. data/test/rails_app/test/unit/team_test.rb +30 -0
  37. data/test/rails_app/test/unit/user_test.rb +23 -4
  38. data/test/rails_app/test/unit/zine_test.rb +28 -0
  39. data/test/rails_app/vendor/plugins/rails_log_stdout/init.rb +43 -0
  40. metadata +41 -34
  41. data/test/rails_app/test/fixtures/tenants.yml +0 -2
  42. data/test/rails_app/test/fixtures/users.yml +0 -11
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ class AuthorTest < ActiveSupport::TestCase
4
+
5
+ context "an author" do
6
+
7
+ setup do
8
+ setup_world()
9
+ @author = Factory( :author ) # stock object for validation testing
10
+ end
11
+
12
+ # validate multi-tenanting structure
13
+ should have_db_column(:tenant_id)
14
+ should_not allow_mass_assignment_of(:tenant_id)
15
+ should "define the current tenant" do
16
+ assert Thread.current[:tenant_id]
17
+ end
18
+ should "match the current tenant" do
19
+ assert_equal @author.tenant_id, Thread.current[:tenant_id]
20
+ end
21
+
22
+ # validate the model
23
+ should belong_to( :user )
24
+ should have_many( :posts )
25
+ should have_many( :team_assets )
26
+ should have_many( :teams ).through( :team_assets )
27
+
28
+ end # context author
29
+
30
+ end # class author
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class CalendarTest < ActiveSupport::TestCase
4
+
5
+ context "a calendar" do
6
+
7
+ setup do
8
+ setup_world()
9
+ @calendar = Factory( :calendar ) # stock object for validation testing
10
+ end
11
+
12
+ # validate multi-tenanting structure
13
+ should have_db_column(:tenant_id)
14
+ should_not allow_mass_assignment_of(:tenant_id)
15
+ should "define the current tenant" do
16
+ assert Thread.current[:tenant_id]
17
+ end
18
+ should "match the current tenant" do
19
+ assert_equal @calendar.tenant_id, Thread.current[:tenant_id]
20
+ end
21
+
22
+ # validate the model
23
+ should have_many( :zines )
24
+ should belong_to( :team )
25
+
26
+ end # context calendar
27
+
28
+ end # class CalendarTest
@@ -1,4 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class HomeHelperTest < ActionView::TestCase
4
+ # Add more helper methods to be used by all tests here...
5
+
6
+
4
7
  end
@@ -0,0 +1,62 @@
1
+ require 'test_helper'
2
+
3
+ class PostTest < ActiveSupport::TestCase
4
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ context "a post" do
7
+
8
+ setup do
9
+ setup_world()
10
+ @post = Factory( :post ) # stock object for validation testing
11
+ end
12
+
13
+ # validate multi-tenanting structure
14
+ should have_db_column(:tenant_id)
15
+ should_not allow_mass_assignment_of(:tenant_id)
16
+ should "define the current tenant" do
17
+ assert Thread.current[:tenant_id]
18
+ end
19
+ should "match the current tenant" do
20
+ assert_equal @post.tenant_id, Thread.current[:tenant_id]
21
+ end
22
+
23
+ # validate the model
24
+ should belong_to( :author )
25
+ should belong_to( :zine )
26
+
27
+ # model-specific tests
28
+ should "get all posts within mangoland" do
29
+ ActiveSupport::TestCase.set_tenant( @mangoland )
30
+ assert_equal (@max_users * @max_teams) + 1, Post.count
31
+ end
32
+
33
+ should "get only author posts in mangoland" do
34
+ ActiveSupport::TestCase.set_tenant( @mangoland )
35
+ x = Author.all[1] # pick an author
36
+ assert_equal 1, x.posts.size
37
+ end
38
+
39
+ should "not get any non-world user posts in mangoland" do
40
+ ActiveSupport::TestCase.set_tenant( @mangoland )
41
+ x = User.all.last # should be from islesmile
42
+ assert x.posts.size.zero?
43
+ end
44
+
45
+ should "see jemell in two tenants with dif posts" do
46
+ ActiveSupport::TestCase.set_tenant( @mangoland )
47
+ assert_equal 2, @jemell.posts.size
48
+ ActiveSupport::TestCase.set_tenant( @islesmile )
49
+ assert_equal 1, @jemell.posts.size
50
+ end
51
+
52
+ should "zoom get all team posts" do
53
+ ActiveSupport::TestCase.set_tenant( @mangoland )
54
+ list = Post.get_team_posts( Author.first.teams.first.id ).all
55
+ assert_equal 3,list.size
56
+ end
57
+
58
+ end # context post
59
+
60
+ # _____________________________________________________________________________
61
+
62
+ end # class test
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ class TeamTest < ActiveSupport::TestCase
4
+
5
+ context "a team" do
6
+
7
+ setup do
8
+ setup_world()
9
+ @team = Factory( :team ) # stock object for validation testing
10
+ end
11
+
12
+ should have_db_column(:tenant_id)
13
+ should_not allow_mass_assignment_of(:tenant_id)
14
+ should "define the current tenant" do
15
+ assert Thread.current[:tenant_id]
16
+ end
17
+ should "match the current tenant" do
18
+ assert_equal @team.tenant_id, Thread.current[:tenant_id]
19
+ end
20
+
21
+ should have_many( :team_assets )
22
+ should have_many( :team_members ).through( :team_assets )
23
+
24
+ should 'ensure team asset creation' do
25
+ assert @team.team_assets.size > 1
26
+ end
27
+
28
+ end # context team
29
+
30
+ end # team
@@ -1,7 +1,26 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class UserTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
4
+
5
+ context "a user" do
6
+
7
+ setup do
8
+ setup_world()
9
+ @user = Factory( :user )
10
+ end
11
+
12
+ should have_one( :author )
13
+ should have_many( :posts ).through( :author )
14
+ should_not allow_value("wild blue").for(:email)
15
+ should have_db_column(:tenant_id)
16
+ should_not allow_mass_assignment_of(:tenant_id)
17
+ should "define the current tenant" do
18
+ assert Thread.current[:tenant_id]
19
+ end
20
+
21
+ end # context user
22
+
23
+ protected
24
+
25
+
26
+ end # class
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class ZineTest < ActiveSupport::TestCase
4
+
5
+ context "a zine" do
6
+
7
+ setup do
8
+ setup_world()
9
+ @zine = Factory( :zine ) # stock object for validation testing
10
+ end
11
+
12
+ # validate multi-tenanting structure
13
+ should have_db_column(:tenant_id)
14
+ should_not allow_mass_assignment_of(:tenant_id)
15
+ should "define the current tenant" do
16
+ assert Thread.current[:tenant_id]
17
+ end
18
+ should "match the current tenant" do
19
+ assert_equal @zine.tenant_id, Thread.current[:tenant_id]
20
+ end
21
+
22
+ # validate the model
23
+ should have_many( :posts )
24
+ should belong_to( :calendar )
25
+
26
+ end # context zine
27
+
28
+ end # class ZineTest
@@ -0,0 +1,43 @@
1
+ begin
2
+
3
+ STDOUT.sync = true
4
+
5
+ def Rails.heroku_stdout_logger
6
+ logger = Logger.new(STDOUT)
7
+ logger.level = Logger.const_get(([ENV['LOG_LEVEL'].to_s.upcase, "INFO"] & %w[DEBUG INFO WARN ERROR FATAL UNKNOWN]).compact.first)
8
+ logger
9
+ end
10
+
11
+ unless Rails.env.test?
12
+ case Rails::VERSION::MAJOR
13
+ when 3 then Rails.logger = Rails.application.config.logger = Rails.heroku_stdout_logger
14
+ when 2 then
15
+ # redefine Rails.logger
16
+ def Rails.logger
17
+ @@logger ||= Rails.heroku_stdout_logger
18
+ end
19
+ %w(
20
+ ActiveSupport::Dependencies
21
+ ActiveRecord::Base
22
+ ActionController::Base
23
+ ActionMailer::Base
24
+ ActionView::Base
25
+ ActiveResource::Base
26
+ ).each do |klass_name|
27
+ begin
28
+ klass = Object
29
+ klass_name.split("::").each { |part| klass = klass.const_get(part) }
30
+ klass.logger = Rails.logger
31
+ rescue
32
+ end
33
+ end
34
+ Rails.cache.logger = Rails.logger rescue nil
35
+ end
36
+ end # unless env.test?
37
+
38
+
39
+ rescue Exception => ex
40
+
41
+ puts "WARNING: Exception during rails_log_stdout init: #{ex.message}"
42
+
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-12 00:00:00.000000000 Z
12
+ date: 2011-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &78085700 !ruby/object:Gem::Requirement
16
+ requirement: &73897630 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *78085700
24
+ version_requirements: *73897630
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: devise
27
- requirement: &78085350 !ruby/object:Gem::Requirement
27
+ requirement: &73896940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.4.8
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *78085350
35
+ version_requirements: *73896940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: pg
38
- requirement: &78084680 !ruby/object:Gem::Requirement
38
+ requirement: &73896110 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *78084680
46
+ version_requirements: *73896110
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: shoulda
49
- requirement: &78084380 !ruby/object:Gem::Requirement
49
+ requirement: &73894450 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *78084380
57
+ version_requirements: *73894450
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &78084090 !ruby/object:Gem::Requirement
60
+ requirement: &73910280 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *78084090
68
+ version_requirements: *73910280
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &78083760 !ruby/object:Gem::Requirement
71
+ requirement: &73909880 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *78083760
79
+ version_requirements: *73909880
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rcov
82
- requirement: &78103470 !ruby/object:Gem::Requirement
82
+ requirement: &73909540 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *78103470
90
+ version_requirements: *73909540
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rdoc
93
- requirement: &78102290 !ruby/object:Gem::Requirement
93
+ requirement: &73909030 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,21 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *78102290
102
- - !ruby/object:Gem::Dependency
103
- name: test-unit
104
- requirement: &78100830 !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: *78100830
101
+ version_requirements: *73909030
113
102
  - !ruby/object:Gem::Dependency
114
103
  name: turn
115
- requirement: &78100490 !ruby/object:Gem::Requirement
104
+ requirement: &73908220 !ruby/object:Gem::Requirement
116
105
  none: false
117
106
  requirements:
118
107
  - - ! '>='
@@ -120,7 +109,7 @@ dependencies:
120
109
  version: '0'
121
110
  type: :development
122
111
  prerelease: false
123
- version_requirements: *78100490
112
+ version_requirements: *73908220
124
113
  description: Transparent Multi-tenanting for hosted Rails 3.1+/Ruby 1.9.2 applications
125
114
  email: dsaronin@gmail.com
126
115
  executables: []
@@ -164,8 +153,14 @@ files:
164
153
  - test/rails_app/app/helpers/home_helper.rb
165
154
  - test/rails_app/app/mailers/.gitkeep
166
155
  - test/rails_app/app/models/.gitkeep
156
+ - test/rails_app/app/models/author.rb
157
+ - test/rails_app/app/models/calendar.rb
158
+ - test/rails_app/app/models/post.rb
159
+ - test/rails_app/app/models/team.rb
160
+ - test/rails_app/app/models/team_asset.rb
167
161
  - test/rails_app/app/models/tenant.rb
168
162
  - test/rails_app/app/models/user.rb
163
+ - test/rails_app/app/models/zine.rb
169
164
  - test/rails_app/app/views/home/index.html.erb
170
165
  - test/rails_app/app/views/layouts/application.html.erb
171
166
  - test/rails_app/config.ru
@@ -190,6 +185,12 @@ files:
190
185
  - test/rails_app/db/migrate/20111012050532_create_tenants.rb
191
186
  - test/rails_app/db/migrate/20111012050600_create_tenants_users.rb
192
187
  - test/rails_app/db/migrate/20111012060818_add_sessions_table.rb
188
+ - test/rails_app/db/migrate/20111012231923_create_posts.rb
189
+ - test/rails_app/db/migrate/20111013050558_create_calendars.rb
190
+ - test/rails_app/db/migrate/20111013050657_create_zines.rb
191
+ - test/rails_app/db/migrate/20111013050753_create_teams.rb
192
+ - test/rails_app/db/migrate/20111013050837_create_team_assets.rb
193
+ - test/rails_app/db/migrate/20111013053403_create_authors.rb
193
194
  - test/rails_app/db/schema.rb
194
195
  - test/rails_app/db/seeds.rb
195
196
  - test/rails_app/lib/assets/.gitkeep
@@ -200,20 +201,26 @@ files:
200
201
  - test/rails_app/public/500.html
201
202
  - test/rails_app/public/favicon.ico
202
203
  - test/rails_app/script/rails
204
+ - test/rails_app/test/ctlr_test_helper.rb
205
+ - test/rails_app/test/factories/units_factory.rb
203
206
  - test/rails_app/test/fixtures/.gitkeep
204
- - test/rails_app/test/fixtures/tenants.yml
205
- - test/rails_app/test/fixtures/users.yml
206
207
  - test/rails_app/test/functional/.gitkeep
207
208
  - test/rails_app/test/functional/home_controller_test.rb
208
209
  - test/rails_app/test/integration/.gitkeep
209
210
  - test/rails_app/test/performance/browsing_test.rb
210
211
  - test/rails_app/test/test_helper.rb
211
212
  - test/rails_app/test/unit/.gitkeep
213
+ - test/rails_app/test/unit/author_test.rb
214
+ - test/rails_app/test/unit/calendar_test.rb
212
215
  - test/rails_app/test/unit/helpers/home_helper_test.rb
216
+ - test/rails_app/test/unit/post_test.rb
217
+ - test/rails_app/test/unit/team_test.rb
213
218
  - test/rails_app/test/unit/tenant_test.rb
214
219
  - test/rails_app/test/unit/user_test.rb
220
+ - test/rails_app/test/unit/zine_test.rb
215
221
  - test/rails_app/vendor/assets/stylesheets/.gitkeep
216
222
  - test/rails_app/vendor/plugins/.gitkeep
223
+ - test/rails_app/vendor/plugins/rails_log_stdout/init.rb
217
224
  - test/test_milia.rb
218
225
  homepage: http://github.com/dsaronin/milia
219
226
  licenses:
@@ -230,7 +237,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
230
237
  version: '0'
231
238
  segments:
232
239
  - 0
233
- hash: -51501887
240
+ hash: -201367885
234
241
  required_rubygems_version: !ruby/object:Gem::Requirement
235
242
  none: false
236
243
  requirements: