cheddargetter_client_rails 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,10 +1,11 @@
1
1
  source "http://rubygems.org"
2
2
  gem "activesupport", ">= 2.3.5"
3
3
  gem "cheddargetter_client", ">= 0.0.2"
4
+ gem 'country_select', '>= 1.1.3'
4
5
 
5
6
  group :development do
7
+ gem 'debugger'
6
8
  gem "rspec"
7
9
  gem "bundler"
8
10
  gem "jeweler"
9
- gem "rcov"
10
- end
11
+ end
@@ -1,18 +1,30 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (3.0.7)
4
+ activesupport (3.2.11)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
5
7
  cheddargetter_client (0.0.2)
6
8
  crack
7
9
  crack (>= 0.3.2)
8
10
  httparty
9
11
  httparty (>= 0.10.0)
12
+ columnize (0.3.6)
13
+ country_select (1.1.3)
10
14
  crack (0.3.2)
11
- diff-lcs (1.1.2)
15
+ debugger (1.3.0)
16
+ columnize (>= 0.3.1)
17
+ debugger-linecache (~> 1.1.1)
18
+ debugger-ruby_core_source (~> 1.1.7)
19
+ debugger-linecache (1.1.2)
20
+ debugger-ruby_core_source (>= 1.1.1)
21
+ debugger-ruby_core_source (1.1.7)
22
+ diff-lcs (1.1.3)
12
23
  git (1.2.5)
13
- httparty (0.10.0)
24
+ httparty (0.10.2)
14
25
  multi_json (~> 1.0)
15
- multi_xml
26
+ multi_xml (>= 0.5.2)
27
+ i18n (0.6.1)
16
28
  jeweler (1.8.4)
17
29
  bundler (~> 1.0)
18
30
  git (>= 1.2.5)
@@ -22,17 +34,16 @@ GEM
22
34
  multi_json (1.5.0)
23
35
  multi_xml (0.5.2)
24
36
  rake (10.0.3)
25
- rcov (0.9.9)
26
37
  rdoc (3.12)
27
38
  json (~> 1.4)
28
- rspec (2.3.0)
29
- rspec-core (~> 2.3.0)
30
- rspec-expectations (~> 2.3.0)
31
- rspec-mocks (~> 2.3.0)
32
- rspec-core (2.3.1)
33
- rspec-expectations (2.3.0)
34
- diff-lcs (~> 1.1.2)
35
- rspec-mocks (2.3.0)
39
+ rspec (2.12.0)
40
+ rspec-core (~> 2.12.0)
41
+ rspec-expectations (~> 2.12.0)
42
+ rspec-mocks (~> 2.12.0)
43
+ rspec-core (2.12.2)
44
+ rspec-expectations (2.12.1)
45
+ diff-lcs (~> 1.1.3)
46
+ rspec-mocks (2.12.2)
36
47
 
37
48
  PLATFORMS
38
49
  ruby
@@ -41,6 +52,7 @@ DEPENDENCIES
41
52
  activesupport (>= 2.3.5)
42
53
  bundler
43
54
  cheddargetter_client (>= 0.0.2)
55
+ country_select (>= 1.1.3)
56
+ debugger
44
57
  jeweler
45
- rcov
46
58
  rspec
data/Rakefile CHANGED
@@ -23,6 +23,8 @@ Jeweler::Tasks.new do |gem|
23
23
  gem.authors = ["Brent Wooden"]
24
24
 
25
25
  gem.add_dependency "cheddargetter_client", ">= 0.0.2"
26
+ gem.add_dependency 'country_select', '>= 1.1.3'
27
+
26
28
  # dependencies defined in Gemfile
27
29
  end
28
30
  Jeweler::RubygemsDotOrgTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cheddargetter_client_rails"
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brent Wooden"]
12
- s.date = "2013-01-25"
12
+ s.date = "2013-01-28"
13
13
  s.description = "Integrates CheddarGetter api with Active Record. Uses cheddargetter_client_ruby."
14
14
  s.email = "brent.wooden@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -36,13 +36,11 @@ Gem::Specification.new do |s|
36
36
  "lib/generators/cheddargetter/templates/cheddargetter.yml",
37
37
  "lib/generators/cheddargetter/templates/cheddargetter_client.rb",
38
38
  "lib/rails/naming.rb",
39
- "lib/rails/record_identifier.rb",
40
39
  "spec/cheddargetter_client_rails/subscription_spec.rb",
41
40
  "spec/cheddargetter_client_rails_spec.rb",
42
41
  "spec/fixtures/users.yml",
43
42
  "spec/generator_spec.rb",
44
43
  "spec/naming_spec.rb",
45
- "spec/record_identifier_spec.rb",
46
44
  "spec/spec_helper.rb"
47
45
  ]
48
46
  s.homepage = "http://github.com/BrentW/cheddargetter_client_rails"
@@ -57,28 +55,34 @@ Gem::Specification.new do |s|
57
55
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
56
  s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
59
57
  s.add_runtime_dependency(%q<cheddargetter_client>, [">= 0.0.2"])
58
+ s.add_runtime_dependency(%q<country_select>, [">= 1.1.3"])
59
+ s.add_development_dependency(%q<debugger>, [">= 0"])
60
60
  s.add_development_dependency(%q<rspec>, [">= 0"])
61
61
  s.add_development_dependency(%q<bundler>, [">= 0"])
62
62
  s.add_development_dependency(%q<jeweler>, [">= 0"])
63
- s.add_development_dependency(%q<rcov>, [">= 0"])
64
63
  s.add_runtime_dependency(%q<cheddargetter_client>, [">= 0.0.2"])
64
+ s.add_runtime_dependency(%q<country_select>, [">= 1.1.3"])
65
65
  else
66
66
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
67
67
  s.add_dependency(%q<cheddargetter_client>, [">= 0.0.2"])
68
+ s.add_dependency(%q<country_select>, [">= 1.1.3"])
69
+ s.add_dependency(%q<debugger>, [">= 0"])
68
70
  s.add_dependency(%q<rspec>, [">= 0"])
69
71
  s.add_dependency(%q<bundler>, [">= 0"])
70
72
  s.add_dependency(%q<jeweler>, [">= 0"])
71
- s.add_dependency(%q<rcov>, [">= 0"])
72
73
  s.add_dependency(%q<cheddargetter_client>, [">= 0.0.2"])
74
+ s.add_dependency(%q<country_select>, [">= 1.1.3"])
73
75
  end
74
76
  else
75
77
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
76
78
  s.add_dependency(%q<cheddargetter_client>, [">= 0.0.2"])
79
+ s.add_dependency(%q<country_select>, [">= 1.1.3"])
80
+ s.add_dependency(%q<debugger>, [">= 0"])
77
81
  s.add_dependency(%q<rspec>, [">= 0"])
78
82
  s.add_dependency(%q<bundler>, [">= 0"])
79
83
  s.add_dependency(%q<jeweler>, [">= 0"])
80
- s.add_dependency(%q<rcov>, [">= 0"])
81
84
  s.add_dependency(%q<cheddargetter_client>, [">= 0.0.2"])
85
+ s.add_dependency(%q<country_select>, [">= 1.1.3"])
82
86
  end
83
87
  end
84
88
 
@@ -1,13 +1,12 @@
1
1
  require 'active_support'
2
- require 'action_controller/record_identifier'
3
2
  require 'cheddargetter_client'
4
- require 'rails/record_identifier'
5
3
  require 'rails/naming'
6
4
 
7
5
  module CheddargetterClientRails
8
6
  autoload :Subscription, 'cheddargetter_client_rails/subscription'
9
7
 
10
8
  def self.included(base)
9
+ attr_accessor :has_subscription_options
11
10
  base.extend ClassMethods
12
11
 
13
12
  def subscription
@@ -102,6 +101,8 @@ module CheddargetterClientRails
102
101
 
103
102
  module ClassMethods
104
103
  def has_subscription(args = {})
104
+ self.class.send(:attr_accessor, :has_subscription_options)
105
+ self.has_subscription_options = args
105
106
  self.customer_code_column = args.delete(:customerCode) || :id
106
107
  raise ArgumentError.new("Record does not respond to #{customer_code_column.to_s}.") if !responds_to_customer_code_column?
107
108
 
@@ -118,6 +119,7 @@ module CheddargetterClientRails
118
119
  self.shared_columns = shared
119
120
 
120
121
  attr_accessor :skip_cheddargetter
122
+ attr_accessible :subscription
121
123
 
122
124
  validate :validate_subscription
123
125
  after_create :create_subscription
@@ -126,7 +128,7 @@ module CheddargetterClientRails
126
128
  end
127
129
 
128
130
  def responds_to_customer_code_column?
129
- self.instance_methods.include?(customer_code_column.to_s) ||
131
+ self.instance_methods.include?(customer_code_column.to_sym) ||
130
132
  self.column_names.include?(customer_code_column.to_s)
131
133
  end
132
134
 
@@ -39,7 +39,9 @@ module CheddargetterClientRails
39
39
  :ccState,
40
40
  :customerCode,
41
41
  :email,
42
- :zip
42
+ :zip,
43
+ :ccExpirationMonth,
44
+ :ccExpirationYear
43
45
 
44
46
  validates_presence_of :firstName,
45
47
  :lastName,
@@ -47,14 +49,21 @@ module CheddargetterClientRails
47
49
  :planCode
48
50
  #:customerCode, generally we call valid before unique identifier is called
49
51
 
50
- validates_presence_of :ccNumber,
51
- :ccExpiration,
52
- :zip
53
-
54
52
  validate :unexpired
55
53
 
56
54
  validate :validates_presence_of_humanized
55
+
56
+ validates_presence_of :ccNumber,
57
+ :ccExpiration,
58
+ :zip, :if => :paid_plan?
57
59
 
60
+ def paid_plan?
61
+ if planCode
62
+ plans = CGClient.plans_get
63
+ !plans.plan(planCode)[:isFree]
64
+ end
65
+ end
66
+
58
67
  def unexpired
59
68
  if ccExpiration.present?
60
69
  month, year = ccExpiration.split("/").collect{|string| string.to_i }
@@ -106,7 +115,7 @@ module CheddargetterClientRails
106
115
  end
107
116
 
108
117
  def new_record?
109
- !Subscription.customers_get({:customer_code =>customerCode})
118
+ !CheddargetterClientRails::Subscription.get(customerCode)
110
119
  end
111
120
 
112
121
  def save
@@ -204,5 +213,33 @@ module CheddargetterClientRails
204
213
  val if val.present?
205
214
  end.compact.present?
206
215
  end
216
+
217
+ def ccExpirationMonth=(month)
218
+ if !expiration_in_valid_format? && expiration_in_valid_year_format?
219
+ @ccExpiration = month + ccExpiration
220
+ elsif !expiration_in_valid_format?
221
+ @ccExpiration = (month + '/')
222
+ end
223
+ end
224
+
225
+ def ccExpirationYear=(year)
226
+ if !expiration_in_valid_format? && expiration_in_valid_month_format?
227
+ @ccExpiration = ccExpiration + year
228
+ elsif !expiration_in_valid_format?
229
+ @ccExpiration = ('/' + year)
230
+ end
231
+ end
232
+
233
+ def expiration_in_valid_format?
234
+ ccExpiration.match(/^\d\d\/\d\d\d\d$/)
235
+ end
236
+
237
+ def expiration_in_valid_month_format?
238
+ ccExpiration.match(/^\d\d\/$/)
239
+ end
240
+
241
+ def expiration_in_valid_year_format?
242
+ ccExpiration.match(/^\/\d\d\d\d$/)
243
+ end
207
244
  end
208
245
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CheddargetterClientRails::Subscription do
4
+ before { ActiveRecord::Base.stub(:connection).and_return mock(:columns => [], :table_exists? => 'true') }
5
+
4
6
  before {
5
7
  class TestUser < ActiveRecord::Base
6
8
  attr_accessor :customer_code, :first_name, :last_name, :plan_code, :email
@@ -19,7 +21,6 @@ describe CheddargetterClientRails::Subscription do
19
21
  end
20
22
  }
21
23
 
22
- before { ActiveRecord::Base.stub(:connection).and_return mock(:columns => []) }
23
24
 
24
25
  let(:user) { TestUser.new }
25
26
  let(:subscription) { CheddargetterClientRails::Subscription.new }
@@ -47,7 +48,7 @@ describe CheddargetterClientRails::Subscription do
47
48
  before {
48
49
  subscription.stub(:add_errors_or_return_valid_response).and_return true
49
50
  subscription.should_receive(:add_errors_or_return_valid_response)
50
- CGClient.should_receive(:new_customer)
51
+ CGClient.should_receive(:customers_new)
51
52
  }
52
53
 
53
54
  it { subject }
@@ -58,7 +59,7 @@ describe CheddargetterClientRails::Subscription do
58
59
  before {
59
60
  subscription.stub(:add_errors_or_return_valid_response).and_return true
60
61
  subscription.should_receive(:add_errors_or_return_valid_response)
61
- CGClient.should_receive(:edit_customer)
62
+ CGClient.should_receive(:customers_edit)
62
63
  }
63
64
 
64
65
  it { subject }
@@ -239,4 +240,163 @@ describe CheddargetterClientRails::Subscription do
239
240
  it { should be_true }
240
241
  end
241
242
  end
243
+
244
+ describe 'ccExpirationMonth=(month)' do
245
+ let(:month) { '44' }
246
+ subject { user.subscription.ccExpiration }
247
+
248
+ context "when there is a value in ccExpiration" do
249
+ context 'when it is already in valid MM/YYYY format' do
250
+ before { user.subscription.ccExpiration = "44/4444"}
251
+ before { user.subscription.ccExpirationMonth = month }
252
+ it { should eq('44/4444')}
253
+ end
254
+
255
+ context 'when it is /YYYY format' do
256
+ before { user.subscription.ccExpiration = "/4444"}
257
+ before { user.subscription.ccExpirationMonth = month }
258
+ it { should eq('44/4444')}
259
+ end
260
+
261
+ context 'when it is in an odd format' do
262
+ before { user.subscription.ccExpiration = "ase"}
263
+ before { user.subscription.ccExpirationMonth = month }
264
+ it { should eq('44/')}
265
+ end
266
+
267
+ context 'when it is already in valid month format' do
268
+ before { user.subscription.ccExpiration = "33/"}
269
+ before { user.subscription.ccExpirationMonth = month }
270
+ it { should eq('44/')}
271
+ end
272
+ end
273
+
274
+ context 'when there is not a value in ccExpiration' do
275
+ before { user.subscription.ccExpiration = ""}
276
+ before { user.subscription.ccExpirationMonth = month }
277
+ it { should eq('44/')}
278
+ end
279
+ end
280
+
281
+ describe'ccExpirationYear=(year)' do
282
+ let(:year) { '4444' }
283
+ subject { user.subscription.ccExpiration }
284
+
285
+ context "when there is a value in ccExpiration" do
286
+ context 'when it is already in valid MM/YYYY format' do
287
+ before { user.subscription.ccExpiration = "44/4444"}
288
+ before { user.subscription.ccExpirationYear = year }
289
+ it { should eq('44/4444')}
290
+ end
291
+
292
+ context 'when it is in MM/ format' do
293
+ before { user.subscription.ccExpiration = "44/"}
294
+ before { user.subscription.ccExpirationYear = year }
295
+ it { should eq('44/4444')}
296
+ end
297
+
298
+ context 'when it is in an odd format' do
299
+ before { user.subscription.ccExpiration = "ase"}
300
+ before { user.subscription.ccExpirationYear = year }
301
+ it { should eq('/4444')}
302
+ end
303
+
304
+ context 'when it is already in valid year format' do
305
+ before { user.subscription.ccExpiration = "/4444"}
306
+ before { user.subscription.ccExpirationYear = year }
307
+ it { should eq('/4444')}
308
+ end
309
+ end
310
+
311
+ context 'when there is not a value in ccExpiration' do
312
+ before { user.subscription.ccExpiration = ""}
313
+ before { user.subscription.ccExpirationYear = year }
314
+ it { should eq('/4444')}
315
+ end
316
+
317
+ end
318
+
319
+ describe 'expiration_in_valid_format?' do
320
+ subject { user.subscription.expiration_in_valid_format? }
321
+ context 'when in valid format' do
322
+ before { user.subscription.ccExpiration = "44/4444"}
323
+ it { should be_true }
324
+ end
325
+
326
+ context 'when not in valid format' do
327
+ context 'with just month' do
328
+ before { user.subscription.ccExpiration = "44/"}
329
+ it { should be_false }
330
+
331
+ end
332
+
333
+ context 'with just year' do
334
+ before { user.subscription.ccExpiration = "/4444"}
335
+ it { should be_false }
336
+ end
337
+
338
+ context 'with odd thigns' do
339
+ before { user.subscription.ccExpiration = "4a/3333"}
340
+ it { should be_false }
341
+ end
342
+
343
+ context 'when blank' do
344
+ before { user.subscription.ccExpiration = ""}
345
+ it { should be_false }
346
+ end
347
+ end
348
+
349
+ end
350
+
351
+ describe 'expiration_in_valid_month_format?' do
352
+ subject { user.subscription.expiration_in_valid_month_format? }
353
+
354
+ context 'when in valid format' do
355
+ before { user.subscription.ccExpiration = '44/'}
356
+ it { should be_true }
357
+ end
358
+
359
+ context 'when not in valid_format' do
360
+ context 'with junk' do
361
+ before { user.subscription.ccExpiration = 'asefas'}
362
+ it { should be_false }
363
+ end
364
+
365
+ context 'when blank' do
366
+ before { user.subscription.ccExpiration = ''}
367
+ it { should be_false }
368
+ end
369
+
370
+ context 'with full date' do
371
+ before { user.subscription.ccExpiration = '44/4444'}
372
+ it { should be_false }
373
+ end
374
+ end
375
+ end
376
+
377
+ describe 'expiration_in_valid_year_format?' do
378
+ subject { user.subscription.expiration_in_valid_year_format? }
379
+
380
+ context 'when in valid format' do
381
+ before { user.subscription.ccExpiration = '/4444'}
382
+ it { should be_true }
383
+ end
384
+
385
+ context 'when not in valid_format' do
386
+ context 'with junk' do
387
+ before { user.subscription.ccExpiration = 'asefas'}
388
+ it { should be_false }
389
+ end
390
+
391
+ context 'when blank' do
392
+ before { user.subscription.ccExpiration = ''}
393
+ it { should be_false }
394
+ end
395
+
396
+ context 'with full date' do
397
+ before { user.subscription.ccExpiration = '44/4444'}
398
+ it { should be_false }
399
+ end
400
+ end
401
+ end
242
402
  end
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
 
4
+ require 'rubygems'
4
5
  require 'rspec'
5
6
  require 'active_record'
6
7
  require 'cheddargetter_client_rails'
@@ -9,7 +10,7 @@ CGEmail = "michael@expectedbehavior.com"
9
10
  CGProductCode = 'GEM_TEST'
10
11
  CGPassword = "DROlOAeQpWey6J2cqTyEzH"
11
12
  CGFreePlanId = "a6a816c8-6d14-11e0-bcd4-40406799fa1e"
12
- CGClient = CheddarGetter::Client.new(:product_code => CGProductCode,
13
+ CGClient = Cheddargetter::Client.new(:product_code => CGProductCode,
13
14
  :username => CGEmail,
14
15
  :password => CGPassword)
15
16
 
@@ -24,5 +25,5 @@ RSpec.configure do |config|
24
25
  end
25
26
 
26
27
  def stub_cheddargetter
27
- CheddarGetter::Client.stub(:new).and_return CGClient
28
+ Cheddargetter::Client.stub(:new).and_return CGClient
28
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheddargetter_client_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-25 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -44,7 +44,23 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: 0.0.2
46
46
  - !ruby/object:Gem::Dependency
47
- name: rspec
47
+ name: country_select
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.1.3
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: debugger
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
@@ -60,7 +76,7 @@ dependencies:
60
76
  - !ruby/object:Gem::Version
61
77
  version: '0'
62
78
  - !ruby/object:Gem::Dependency
63
- name: bundler
79
+ name: rspec
64
80
  requirement: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
@@ -76,7 +92,7 @@ dependencies:
76
92
  - !ruby/object:Gem::Version
77
93
  version: '0'
78
94
  - !ruby/object:Gem::Dependency
79
- name: jeweler
95
+ name: bundler
80
96
  requirement: !ruby/object:Gem::Requirement
81
97
  none: false
82
98
  requirements:
@@ -92,7 +108,7 @@ dependencies:
92
108
  - !ruby/object:Gem::Version
93
109
  version: '0'
94
110
  - !ruby/object:Gem::Dependency
95
- name: rcov
111
+ name: jeweler
96
112
  requirement: !ruby/object:Gem::Requirement
97
113
  none: false
98
114
  requirements:
@@ -123,6 +139,22 @@ dependencies:
123
139
  - - ! '>='
124
140
  - !ruby/object:Gem::Version
125
141
  version: 0.0.2
142
+ - !ruby/object:Gem::Dependency
143
+ name: country_select
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: 1.1.3
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: 1.1.3
126
158
  description: Integrates CheddarGetter api with Active Record. Uses cheddargetter_client_ruby.
127
159
  email: brent.wooden@gmail.com
128
160
  executables: []
@@ -150,13 +182,11 @@ files:
150
182
  - lib/generators/cheddargetter/templates/cheddargetter.yml
151
183
  - lib/generators/cheddargetter/templates/cheddargetter_client.rb
152
184
  - lib/rails/naming.rb
153
- - lib/rails/record_identifier.rb
154
185
  - spec/cheddargetter_client_rails/subscription_spec.rb
155
186
  - spec/cheddargetter_client_rails_spec.rb
156
187
  - spec/fixtures/users.yml
157
188
  - spec/generator_spec.rb
158
189
  - spec/naming_spec.rb
159
- - spec/record_identifier_spec.rb
160
190
  - spec/spec_helper.rb
161
191
  homepage: http://github.com/BrentW/cheddargetter_client_rails
162
192
  licenses:
@@ -173,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
203
  version: '0'
174
204
  segments:
175
205
  - 0
176
- hash: 3013483079917417626
206
+ hash: 971876707136878326
177
207
  required_rubygems_version: !ruby/object:Gem::Requirement
178
208
  none: false
179
209
  requirements:
@@ -1,7 +0,0 @@
1
- module ActionController::RecordIdentifier
2
- def dom_class(record_or_class, prefix = nil)
3
- singular = ActiveModel::Naming.singular(record_or_class)
4
- value = prefix ? "#{prefix}#{JOIN}#{singular}" : singular
5
- value == "cheddargetter_client_rails_subscription" ? "subscription" : value
6
- end
7
- end
@@ -1,51 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "RecordIdentifier" do
4
- before {
5
- class TestUser < ActiveRecord::Base
6
- attr_accessor :customer_code, :first_name, :last_name, :plan_code, :email
7
-
8
- def self.column_names
9
- []
10
- end
11
-
12
- has_subscription :customerCode => :customer_code,
13
- :firstName => :first_name,
14
- :lastName => :last_name,
15
- :ccFirstName => :first_name,
16
- :ccLastName => :last_name,
17
- :planCode => :plan_code
18
-
19
- end
20
- }
21
-
22
- before { ActiveRecord::Base.stub(:connection).and_return mock(:columns => []) }
23
-
24
- describe 'dom_class(record)' do
25
- subject { ActionController::RecordIdentifier.dom_class(value) }
26
-
27
- context 'called with class' do
28
- context 'called with a CheddargetterClientRails::Subscription class' do
29
- let(:value) { CheddargetterClientRails::Subscription }
30
- it { should eq("subscription") }
31
- end
32
-
33
- context 'called with other classes' do
34
- let(:value) { TestUser }
35
- it { should eq("test_user") }
36
- end
37
- end
38
-
39
- context 'called with object' do
40
- context 'called with a CheddargetterClientRails::Subscription class' do
41
- let(:value) { CheddargetterClientRails::Subscription.new }
42
- it { should eq("subscription") }
43
- end
44
-
45
- context 'called with other classes' do
46
- let(:value) { TestUser.new }
47
- it { should eq("test_user") }
48
- end
49
- end
50
- end
51
- end