This repository was archived by the owner on Jan 8, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ def activity_source_information(activity)
1515 def customer_link ( customer_id )
1616 return unless customer_link_enabled?
1717 customer_url = UberZeit . config . customer_url
18- customer = Customer . where ( id : customer_id ) . last || customer_id
18+ customer = Customer . where ( id : customer_id ) . last
19+ return if customer . nil?
1920 link_to ( customer , ( customer_url % customer . number ) )
2021 end
2122
Original file line number Diff line number Diff line change 2323 it { should eq '.otrs: <a href="https://otrs.howdoyouturnthison/otrs/index.pl?Action=AgentTicketZoom&TicketNumber=42">#42</a> und .redmine: <a href="https://redmine.yolo/issues/1337">#1337</a>' }
2424 end
2525 end
26+
27+ describe '#customer_link' do
28+ let ( :customer_id ) { 1337 }
29+ subject { helper . customer_link ( customer_id ) }
30+
31+ context 'without customer_url' do
32+ before ( :each ) { UberZeit . config . customer_url = nil }
33+
34+ it { should be_nil }
35+ end
36+
37+ context 'with customer_url' do
38+ before ( :each ) { UberZeit . config . customer_url = 'https://www.nine.ch/customers/%s' }
39+
40+ context 'with a deleted customer' do
41+ let ( :customer_id ) { FactoryGirl . create ( :customer ) . tap { |c | c . delete } . id }
42+
43+ it { should be_nil }
44+ end
45+
46+ context 'with an existing customer' do
47+ let ( :customer ) { FactoryGirl . create ( :customer ) }
48+ let ( :customer_id ) { customer . id }
49+
50+ it { should include "https://www.nine.ch/customers/#{ customer . number } " }
51+ end
52+ end
53+ end
2654end
You can’t perform that action at this time.
0 commit comments