Skip to content

Instantly share code, notes, and snippets.

@jferris
Forked from r00k/gist:5111344
Created March 7, 2013 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jferris/5111428 to your computer and use it in GitHub Desktop.
Save jferris/5111428 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe 'products/_prime_purchase.html.erb' do
it "tries to sell the user on Prime" do
view.stubs(currently_viewing_subscription_product?: false)
view.stubs(current_user_has_active_subscription?: false)
view.stubs(subscription_product: stub('subscription_product', name: 'foo'))
render template: 'products/_prime_purchase'
rendered.should include(I18n.t('shared.subscription_call_to_action'))
end
it "does not sell the user on Prime if they're subscribed already" do
view.stubs(currently_viewing_subscription_product?: false)
view.stubs(current_user_has_active_subscription?: true)
view.stubs(subscription_product: stub('subscription_product'))
render template: 'products/_prime_purchase'
rendered.should_not include(I18n.t('shared.subscription_call_to_action'))
end
it "does not sell the user on Prime if they're currently viewing Prime's product show page" do
view.stubs(currently_viewing_subscription_product?: true)
render template: 'products/_prime_purchase'
rendered.should_not include(I18n.t('shared.subscription_call_to_action'))
end
end
<% if !currently_viewing_subscription_product? %>
<% if subscription_product && !current_user_has_active_subscription? %>
<h2>Access this and all our other products by subscribing to <%= subscription_product.name %></h2>
<div class="license">
<%= link_to product_path(subscription_product),
class: 'license-button button' do %>
Get unlimited access
<% end %>
</div>
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment