scottmotte-merb_auth_slice_multisite 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +2 -2
- data/app/models/site.rb +0 -10
- data/config/dependencies.rb +0 -1
- data/spec/models/site_spec.rb +0 -27
- data/spec/spec_helper.rb +3 -9
- metadata +2 -2
data/VERSION.yml
CHANGED
data/app/models/site.rb
CHANGED
@@ -4,7 +4,6 @@ class Site
|
|
4
4
|
|
5
5
|
# Schema
|
6
6
|
property :id, Serial
|
7
|
-
property :domain, String, :nullable => :false, :length => (1..40), :unique => true, :format => /(\.[a-z]{2,4})$/
|
8
7
|
property :subdomain, String, :nullable => :false, :length => (1..40), :unique => true, :format => /^[a-zA-Z0-9\-]*?$/
|
9
8
|
property :created_at, DateTime
|
10
9
|
property :updated_at, DateTime
|
@@ -24,13 +23,4 @@ class Site
|
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
|
-
# Hooks
|
28
|
-
before :valid?, :remove_http_and_www
|
29
|
-
def remove_http_and_www
|
30
|
-
if domain
|
31
|
-
domain.gsub!('http://', '')
|
32
|
-
domain.gsub!('www.', '')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
26
|
end
|
data/config/dependencies.rb
CHANGED
@@ -22,7 +22,6 @@ dependency "merb-param-protection", merb_gems_version
|
|
22
22
|
dependency "merb-exceptions", merb_gems_version
|
23
23
|
|
24
24
|
dependency "data_objects", do_gems_version
|
25
|
-
dependency "do_mysql", do_gems_version # If using another database, replace this
|
26
25
|
dependency "dm-core", dm_gems_version
|
27
26
|
dependency "dm-aggregates", dm_gems_version
|
28
27
|
dependency "dm-migrations", dm_gems_version
|
data/spec/models/site_spec.rb
CHANGED
@@ -10,23 +10,12 @@ describe Site do
|
|
10
10
|
it "should be valid when new" do
|
11
11
|
@site.should be_valid
|
12
12
|
end
|
13
|
-
|
14
|
-
it "should be invalid when domain is not unique" do
|
15
|
-
@site.save
|
16
|
-
@site.should be_valid
|
17
|
-
|
18
|
-
@site2 = Site.new(valid_site_attributes)
|
19
|
-
@site2.subdomain = "differentsubdomain"
|
20
|
-
@site2.save
|
21
|
-
@site2.should_not be_valid
|
22
|
-
end
|
23
13
|
|
24
14
|
it "should be invalid when subdomain is not unique" do
|
25
15
|
@site.save
|
26
16
|
@site.should be_valid
|
27
17
|
|
28
18
|
@site2 = Site.new(valid_site_attributes)
|
29
|
-
@site2.domain = "http://differenturl.com"
|
30
19
|
@site2.save
|
31
20
|
@site2.should_not be_valid
|
32
21
|
end
|
@@ -39,16 +28,6 @@ describe Site do
|
|
39
28
|
end
|
40
29
|
end
|
41
30
|
|
42
|
-
it "should be invalid if missing a domain extension" do
|
43
|
-
@site.save
|
44
|
-
@site.domain.should match(/(\.[a-z]{2,4})$/)
|
45
|
-
|
46
|
-
@site2 = Site.new(valid_site_attributes)
|
47
|
-
@site2.domain = "secondmemorial.com"
|
48
|
-
@site2.save
|
49
|
-
@site2.domain.should match(/(\.[a-z]{2,4})$/)
|
50
|
-
end
|
51
|
-
|
52
31
|
it "should only allow text and numbers as a subdomain and should not allow any odd characters or whitespace" do
|
53
32
|
@site.save
|
54
33
|
@site.subdomain.should match(/^[a-zA-Z0-9\-]*?$/)
|
@@ -63,12 +42,6 @@ describe Site do
|
|
63
42
|
@site3.save
|
64
43
|
@site3.subdomain.should_not match(/^[a-zA-Z0-9\-]*?$/)
|
65
44
|
end
|
66
|
-
|
67
|
-
it "should clean http:// and www from the domain" do
|
68
|
-
@site.save
|
69
|
-
@site.domain.should_not include("http://")
|
70
|
-
@site.domain.should_not include("www.")
|
71
|
-
end
|
72
45
|
|
73
46
|
it "should respond to users" do
|
74
47
|
@site.save
|
data/spec/spec_helper.rb
CHANGED
@@ -68,27 +68,21 @@ end
|
|
68
68
|
# =============================================================================
|
69
69
|
def valid_site_attributes(options = {})
|
70
70
|
{
|
71
|
-
:
|
72
|
-
:subdomain => 'example',
|
73
|
-
:id => 1
|
71
|
+
:subdomain => 'example'
|
74
72
|
}.merge(options)
|
75
73
|
end
|
76
74
|
|
77
75
|
def valid_second_site_attributes(options = {})
|
78
76
|
{
|
79
|
-
:domain => 'http://www.example2.org',
|
80
77
|
:subdomain => 'example2',
|
81
|
-
:active => true
|
82
|
-
:id => 2
|
78
|
+
:active => true
|
83
79
|
}.merge(options)
|
84
80
|
end
|
85
81
|
|
86
82
|
def valid_third_site_attributes(options = {})
|
87
83
|
{
|
88
|
-
:domain => 'http://www.example3.org',
|
89
84
|
:subdomain => 'example3',
|
90
|
-
:active => true
|
91
|
-
:id => 3
|
85
|
+
:active => true
|
92
86
|
}.merge(options)
|
93
87
|
end
|
94
88
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scottmotte-merb_auth_slice_multisite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- scottmotte
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|