Skip to content

Commit a82f623

Browse files
committed
Merge pull request #218 from YaroSpace/bounty_389_undefined_method_banner
Bounty 389 undefined method banner
2 parents 7cae94b + 1835006 commit a82f623

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

app/helpers/protips_helper.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ def users_background_image
6767
location_image_url_for(@user)
6868
elsif @protip && !@protip.new_record?
6969
location_image_url_for(@protip.user)
70-
else
71-
location_image_url_for(current_user)
7270
end
7371
end
7472

spec/helpers/protips_helper_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,42 @@
44
expect(helper.protip_search_results_to_render(nil)).to be_nil
55
end
66
end
7+
8+
describe '#users_background_image' do
9+
context 'user is logged in' do
10+
it 'returns #location_image_url_for @user' do
11+
assign(:user, 'test_user')
12+
allow(helper).to receive(:location_image_url_for).with('test_user').and_return('image_path')
13+
expect(helper.users_background_image).to eq 'image_path'
14+
end
15+
end
16+
17+
context 'user is not logged in' do
18+
it 'returns nil' do
19+
assign(:user, nil)
20+
expect(helper.users_background_image).to be_nil
21+
end
22+
end
23+
24+
context 'protip is set' do
25+
it 'returns #location_image_url_for @protip.user if @protip is not new_record' do
26+
@protip = double('protip', 'user' => 'test_user', 'new_record?' => false)
27+
allow(helper).to receive(:location_image_url_for).with('test_user').and_return('image_path')
28+
expect(helper.users_background_image).to eq 'image_path'
29+
end
30+
31+
it 'returns nil if @protip is new_record' do
32+
@protip = double('protip', 'user' => 'test_user', 'new_record?' => true)
33+
expect(helper.users_background_image).to be_nil
34+
end
35+
end
36+
37+
context 'protip is not set' do
38+
it 'returns nil' do
39+
assign(:protip, nil)
40+
expect(helper.users_background_image).to be_nil
41+
end
42+
end
43+
end
44+
745
end

0 commit comments

Comments
 (0)