shortener 0.6.1 → 0.6.2
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.
- checksums.yaml +4 -4
- data/app/helpers/shortener/shortener_helper.rb +9 -7
- data/lib/shortener/version.rb +1 -1
- data/spec/helpers/shortener_helper_spec.rb +11 -4
- 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: ae732fd2135a915ebf0565d0350279894ed29ddc
|
4
|
+
data.tar.gz: 730ea8bc1f3c867ae3f3caa6ca2695399d61b8fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628ab6bb9d1bc641a3727e26643b617df6092aecb20ee0f9cdc4418b889418a85609b45231754fc462d813e203709ba48b61a7972520efbef1ef65f93e65abb9
|
7
|
+
data.tar.gz: 3adb8897c37e618ce3fe27c999895b1519ae9e97d2d370ad2d16e2a27a6cca94ae646feb97617bcd370d607d5ce50244c244535c5c30c4f122e9d650ceae1865
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Shortener::ShortenerHelper
|
2
2
|
|
3
3
|
# generate a url from a url string
|
4
|
-
def short_url(url, owner: nil, custom_key: nil, expires_at: nil, fresh: false, url_options: {})
|
5
|
-
short_url = Shortener::ShortenedUrl.generate(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
def short_url(url, owner: nil, custom_key: nil, expires_at: nil, fresh: false, category: nil, url_options: {})
|
5
|
+
short_url = Shortener::ShortenedUrl.generate(
|
6
|
+
url,
|
7
|
+
owner: owner,
|
8
|
+
custom_key: custom_key,
|
9
|
+
expires_at: expires_at,
|
10
|
+
fresh: fresh,
|
11
|
+
category: category
|
12
|
+
)
|
11
13
|
|
12
14
|
if short_url
|
13
15
|
options = { controller: :"/shortener/shortened_urls", action: :show, id: short_url.unique_key, only_path: false }.merge(url_options)
|
data/lib/shortener/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe Shortener::ShortenerHelper, type: :helper do
|
|
7
7
|
|
8
8
|
context 'without user or custom key' do
|
9
9
|
before do
|
10
|
-
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: nil, custom_key: nil, expires_at: nil, fresh: false).and_return(shortened_url)
|
10
|
+
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: nil, custom_key: nil, expires_at: nil, fresh: false, category: nil).and_return(shortened_url)
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'short url was generated' do
|
@@ -30,25 +30,32 @@ describe Shortener::ShortenerHelper, type: :helper do
|
|
30
30
|
context 'with owner' do
|
31
31
|
let(:owner) { double('User') }
|
32
32
|
it 'sends user to generate function' do
|
33
|
-
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: owner, custom_key: nil, expires_at: nil, fresh: false)
|
33
|
+
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: owner, custom_key: nil, expires_at: nil, fresh: false, category: nil)
|
34
34
|
helper.short_url(destination, owner: owner)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'with custom_key' do
|
39
39
|
it 'sends custom key code to generate function' do
|
40
|
-
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: nil, custom_key: 'custkey', expires_at: nil, fresh: false)
|
40
|
+
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: nil, custom_key: 'custkey', expires_at: nil, fresh: false, category: nil)
|
41
41
|
helper.short_url(destination, custom_key: 'custkey')
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'with expires_at' do
|
46
46
|
it 'sends custom key code to generate function' do
|
47
|
-
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: nil, custom_key: nil, expires_at: 'testtime', fresh: false)
|
47
|
+
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: nil, custom_key: nil, expires_at: 'testtime', fresh: false, category: nil)
|
48
48
|
helper.short_url(destination, expires_at: 'testtime')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
context 'with category' do
|
53
|
+
it 'sends custom key code to generate function' do
|
54
|
+
expect(Shortener::ShortenedUrl).to receive(:generate).with(destination, owner: nil, custom_key: nil, expires_at: nil, fresh: false, category: 'testcat')
|
55
|
+
helper.short_url(destination, category: 'testcat')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
52
59
|
context 'with url options for https and subdomain' do
|
53
60
|
let(:short_url) { double('ShortUrl', unique_key: 'knownkey') }
|
54
61
|
it 'sends custom key code to generate function' do
|