pco-url 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pco/url/version.rb +1 -1
- data/lib/pco/url.rb +5 -21
- data/spec/pco_url_spec.rb +14 -24
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffffc4ec52600a23d033d2b75f4a7f0bc74db900
|
4
|
+
data.tar.gz: 7cd6fae8170dc6493aaffc2ad12ad776142cefcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fffaf131fa4586c17340d679e0545a314167dea60c1c027cac95b87ef0ad663295259e89d5a61b6fba0e337f96febd86e3ac6c49b64aecfffbf02dfa1f101c09
|
7
|
+
data.tar.gz: 67595608b41b2d9ea1493dac83bb938986f5def9834b6a6dd5328017bb4f59b4847068cce870b310f69907dc5f80a8ce46725c21010494d38457be4660924f8d
|
data/lib/pco/url/version.rb
CHANGED
data/lib/pco/url.rb
CHANGED
@@ -4,29 +4,12 @@ module PCO
|
|
4
4
|
class URL
|
5
5
|
|
6
6
|
class << self
|
7
|
-
def applications
|
8
|
-
@applications ||= [
|
9
|
-
:accounts,
|
10
|
-
:avatars,
|
11
|
-
:services,
|
12
|
-
:check_ins,
|
13
|
-
:people,
|
14
|
-
:registrations,
|
15
|
-
:resources
|
16
|
-
]
|
17
|
-
end
|
18
|
-
attr_writer :applications
|
19
|
-
|
20
7
|
def method_missing(method_name)
|
21
|
-
|
22
|
-
|
23
|
-
env_var = method_name.to_s.upcase + "_URL"
|
8
|
+
app_name = method_name.to_s.gsub("_", "-")
|
9
|
+
env_var = method_name.to_s.upcase + "_URL"
|
24
10
|
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
super
|
29
|
-
end
|
11
|
+
# Try "CHECK_INS_URL" then url_for_app("check-ins")
|
12
|
+
ENV[env_var] || url_for_app(app_name)
|
30
13
|
end
|
31
14
|
|
32
15
|
private
|
@@ -48,5 +31,6 @@ module PCO
|
|
48
31
|
end
|
49
32
|
end
|
50
33
|
end
|
34
|
+
|
51
35
|
end
|
52
36
|
end
|
data/spec/pco_url_spec.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
+
Applications = [
|
4
|
+
:accounts,
|
5
|
+
:avatars,
|
6
|
+
:services,
|
7
|
+
:check_ins,
|
8
|
+
:people,
|
9
|
+
:registrations,
|
10
|
+
:resources
|
11
|
+
]
|
12
|
+
|
3
13
|
describe PCO::URL do
|
4
14
|
describe "defaults" do
|
5
15
|
describe "development" do
|
@@ -7,7 +17,7 @@ describe PCO::URL do
|
|
7
17
|
Rails.env = "development"
|
8
18
|
end
|
9
19
|
|
10
|
-
|
20
|
+
Applications.map(&:to_s).each do |app|
|
11
21
|
it "has an #{app} URL" do
|
12
22
|
expect(PCO::URL.send(app)).to eq("http://#{app.gsub('_','-')}.pco.dev")
|
13
23
|
end
|
@@ -19,7 +29,7 @@ describe PCO::URL do
|
|
19
29
|
Rails.env = "staging"
|
20
30
|
end
|
21
31
|
|
22
|
-
|
32
|
+
Applications.map(&:to_s).each do |app|
|
23
33
|
it "has an #{app} URL" do
|
24
34
|
expect(PCO::URL.send(app)).to eq("https://#{app.gsub('_','-')}-staging.planningcenteronline.com")
|
25
35
|
end
|
@@ -31,7 +41,7 @@ describe PCO::URL do
|
|
31
41
|
Rails.env = "production"
|
32
42
|
end
|
33
43
|
|
34
|
-
|
44
|
+
Applications.map(&:to_s).each do |app|
|
35
45
|
it "has an #{app} URL" do
|
36
46
|
expect(PCO::URL.send(app)).to eq("https://#{app.gsub('_','-')}.planningcenteronline.com")
|
37
47
|
end
|
@@ -43,7 +53,7 @@ describe PCO::URL do
|
|
43
53
|
Rails.env = "test"
|
44
54
|
end
|
45
55
|
|
46
|
-
|
56
|
+
Applications.map(&:to_s).each do |app|
|
47
57
|
it "has an #{app} URL" do
|
48
58
|
expect(PCO::URL.send(app)).to eq("http://#{app.gsub('_','-')}.pco.test")
|
49
59
|
end
|
@@ -88,24 +98,4 @@ describe PCO::URL do
|
|
88
98
|
end
|
89
99
|
end
|
90
100
|
|
91
|
-
describe "custom applications" do
|
92
|
-
before do
|
93
|
-
Rails.env = "development"
|
94
|
-
ENV["DEPLOY_ENV"] = nil
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "adding an app" do
|
98
|
-
it "adds a URL method for bazinga" do
|
99
|
-
PCO::URL.applications += [:bazinga]
|
100
|
-
expect(PCO::URL.bazinga).to eq("http://bazinga.pco.dev")
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "removing an app" do
|
105
|
-
it "removes the URL method for accounts" do
|
106
|
-
PCO::URL.applications -= [:accounts]
|
107
|
-
expect{PCO::URL.accounts}.to raise_error(NoMethodError)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
101
|
end
|