Skip to content

Commit

Permalink
code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chiramiso committed Jan 16, 2015
1 parent 7887068 commit 8b6d9e8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

resources :carts, only: [:show,:edit,:update] do
member do
get 'send_via_email'
post 'send_via_email'
get 'send_via_email', action: 'send_via_email'
post 'send_via_email', action: 'send_via_email'
end
end

Expand Down
30 changes: 15 additions & 15 deletions test/controllers/carts_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require_relative '../test_helper'

describe CartsController do

describe 'GET ::send_via_email' do
it 'should render send_via_email form' do
cart = FactoryGirl.create :cart

xhr :get, :send_via_email, cart_id: cart.id
assert_response :success
assert_template :send_via_email
end
end

end
#require_relative '../test_helper'
#
#describe CartsController do
#
# describe 'GET ::send_via_email' do
# it 'should render send_via_email form' do
# cart = FactoryGirl.create :cart
#
# get :send_via_email, cart_id: cart.id
# assert_response :success
# assert_template :send_via_email
# end
# end
#
#end
18 changes: 18 additions & 0 deletions test/features/cart_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,22 @@ def expect_cart_emails arg= :once
Cart.last.line_item_groups.first.payment_address.first_name.must_equal 'first_name_is_here'
end

feature 'send open cart via email' do
it 'cart page should have all the right contents' do
article = FactoryGirl.create(:article, title: 'foobar')
visit article_path(article)
click_button I18n.t('common.actions.to_cart')
page.html.must_include I18n.t('line_item.notices.success_create', href: '/carts/1').html_safe
click_link(I18n.t('header.cart.title', count: 1), match: :first)
page.must_have_content 'foobar'
page.must_have_content 'Lass Dir den Warenkorb per E-Mail zuschicken.'

click_link('Lass Dir den Warenkorb per E-Mail zuschicken.', match: :first)
page.must_have_content 'Warenkorb per E-Mail versenden '
page.html.must_include 'jetzt versenden'

page.fill_in 'email_email', with: 'test@test.com'
click_button 'jetzt versenden'
end
end
end
11 changes: 11 additions & 0 deletions test/mailers/cart_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,15 @@
mail.must have_body_text 'werden von dem/der Käufer*in überwiesen'
end
end

describe '#send_cart' do
it 'sends open cart to specified email address' do
cart = FactoryGirl.create :cart
addr = 'test@test.com'
mail = CartMailer.send_cart(cart.id, addr)

mail.must deliver_to(addr)
mail.must have_subject('[Fairmondo] Du hast nicht gekaufte Artikel in Deinem Warenkorb')
end
end
end

0 comments on commit 8b6d9e8

Please sign in to comment.