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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe28326cb43bf61b21d93e6b358942fc5252c761
4
- data.tar.gz: 9f974fd5c92613dbbd1548d9257c3b24a097cf1b
3
+ metadata.gz: ae732fd2135a915ebf0565d0350279894ed29ddc
4
+ data.tar.gz: 730ea8bc1f3c867ae3f3caa6ca2695399d61b8fc
5
5
  SHA512:
6
- metadata.gz: b60cc661851633cd890c7ce4c2c8aa0329b6be9132f05385104fe289bd47f0fe4fb11a121688d333bf4be078e939228829715c43b4f67f473b7c2e558e428a0e
7
- data.tar.gz: 3e1376fb0c2f376672b14338dad3e6e58c3f76c051a3a863640e3b2fe44708420608d2817cef8368f2be74ca8e32ca7b095696d9e2c96e84ef079d884b29519d
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(url,
6
- owner: owner,
7
- custom_key: custom_key,
8
- expires_at: expires_at,
9
- fresh: fresh
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)
@@ -1,3 +1,3 @@
1
1
  module Shortener
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shortener
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James P. McGrath