Skip to content

Commit b750249

Browse files
YaroSpacejust3ws
authored andcommitted
added spec for #users_background_image
1 parent 71ac62e commit b750249

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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)