Skip to content

Commit

Permalink
#1257 test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chiramiso committed Jan 20, 2015
1 parent 03c24ea commit 06d5838
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/controllers/carts_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require_relative '../test_helper'

describe CartsController do
it 'should render empty cart template when user has no cart' do
get :empty_cart
assert_response :success
assert_template :empty_cart
end
end
9 changes: 9 additions & 0 deletions test/features/cart_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ def expect_cart_emails arg= :once
CartMailer.expects(:buyer_email).returns(Mail::Message.new)
end

feature 'Empty cart' do
it 'header should show link to empty cart' do
visit root_path
page.html.must_include I18n.t('header.cart.title', count: 0)
click_link(I18n.t('header.cart.title', count: 0), match: :first)
page.must_have_content 'Dein Warenkorb ist leer.'
end
end

feature 'Adding an Article to the cart' do

scenario 'anonymous user adds article to his cart' do
Expand Down
3 changes: 3 additions & 0 deletions test/policies/cart_policy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@
it { subject.must_deny(:show) }
it { subject.must_deny(:edit) }
it { subject.must_deny(:update) }
it { subject.must_permit(:empty_cart) }
end

describe "for a random logged-in user" do
let(:user) { FactoryGirl.create :user }
it { subject.must_deny(:show) }
it { subject.must_deny(:edit) }
it { subject.must_deny(:update) }
it { subject.must_permit(:empty_cart) }
end

describe "for the owning user" do
let(:user) { cart.user }
it { subject.must_permit(:show) }
it { subject.must_permit(:edit) }
it { subject.must_permit(:update) }
it { subject.must_deny(:empty_cart) }
end
end

0 comments on commit 06d5838

Please sign in to comment.