Skip to content

Bounty 389 undefined method banner #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/helpers/protips_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ def users_background_image
location_image_url_for(@user)
elsif @protip && !@protip.new_record?
location_image_url_for(@protip.user)
else
location_image_url_for(current_user)
end
end

Expand Down
38 changes: 38 additions & 0 deletions spec/helpers/protips_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,42 @@
expect(helper.protip_search_results_to_render(nil)).to be_nil
end
end

describe '#users_background_image' do
context 'user is logged in' do
it 'returns #location_image_url_for @user' do
assign(:user, 'test_user')
allow(helper).to receive(:location_image_url_for).with('test_user').and_return('image_path')
expect(helper.users_background_image).to eq 'image_path'
end
end

context 'user is not logged in' do
it 'returns nil' do
assign(:user, nil)
expect(helper.users_background_image).to be_nil
end
end

context 'protip is set' do
it 'returns #location_image_url_for @protip.user if @protip is not new_record' do
@protip = double('protip', 'user' => 'test_user', 'new_record?' => false)
allow(helper).to receive(:location_image_url_for).with('test_user').and_return('image_path')
expect(helper.users_background_image).to eq 'image_path'
end

it 'returns nil if @protip is new_record' do
@protip = double('protip', 'user' => 'test_user', 'new_record?' => true)
expect(helper.users_background_image).to be_nil
end
end

context 'protip is not set' do
it 'returns nil' do
assign(:protip, nil)
expect(helper.users_background_image).to be_nil
end
end
end

end