Created
September 13, 2017 06:33
-
-
Save brunoocasali/55000d7a7b9731cf57d27cf85ecaa03c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'Many products use case' do | |
include_context 'logged with valid querystring' | |
let!(:workflow) { nil } | |
let!(:sale_item2) do | |
FactoryGirl.create :sale_item, sale: sale, product: product2 | |
end | |
let(:build_params) do | |
{ rate: 1, user: user, store: store, text: Faker::Lorem.sentence } | |
end | |
let(:product2) { FactoryGirl.create :product } | |
let!(:opinion) { nil } | |
let!(:store_review) { nil } | |
let(:review_page) { /review\/sale_items\/#{sale_item.id}\/opinions\/new/ } | |
let(:review_page2) { /review\/sale_items\/#{sale_item2.id}\/opinions\/new/ } | |
let(:store_review_page) { /review\/sales\/#{sale.id}\/store_reviews\/new/ } | |
let(:success_page) { /success/ } | |
let(:home_page) { /\/\?email=/ } | |
before { visit "/#{valid_querystring}" } | |
# start page needs to show home | |
# click into avaliar | |
# shows review page | |
# creates review | |
# redirs to home | |
# | |
# when last product & store already reviewed | |
# creates review | |
# redirs to success page | |
# | |
# when last product & not store reviewed yet | |
# redirs to storereview | |
# creates store_review | |
# redirs to success page | |
context 'in a fresh start' do | |
it 'renders home page' do | |
expect(sale.sale_items.count).to eq(2) | |
expect(page).to have_current_path(home_page) | |
end | |
it 'success after opinion -> opinion -> store' do | |
# click_link('', href: review_page) | |
# expect(page).to have_current_path review_page | |
# create_opinion | |
# click_link('', href: review_page2) | |
# expect(page).to have_current_path review_page2 | |
# create_opinion | |
# expect(page).to have_current_path(store_review_page) | |
# create_store_review | |
# expect(page).to have_current_path(success_page) | |
puts "\n\nopinion -> opinion -> store" | |
puts "[deveria estar na: home ] current_path #{page.current_path}" | |
click_link('', href: review_page) | |
puts "[deveria estar na: opinions/#{sale_item.id}/] current_path #{page.current_path}" | |
create_opinion | |
puts "[deveria estar na: home ] current_path #{page.current_path}" | |
click_link('', href: review_page2) | |
puts "[deveria estar na: opinions/#{sale_item2.id}/] current_path #{page.current_path}" | |
create_opinion | |
puts "[deveria estar na: store_reviews/] current_path #{page.current_path}" | |
create_store_review | |
puts "[deveria estar na: success/] current_path #{page.current_path}" | |
end | |
it 'success after opinion -> store -> opinion' do | |
# click_link('', href: review_page) | |
# expect(page).to have_current_path review_page | |
# create_opinion | |
# expect(page).to have_current_path(home_page) | |
# click_link('', href: store_review_page) | |
# expect(page).to have_current_path(store_review_page) | |
# create_store_review | |
# expect(page).to have_current_path(home_page) | |
# expect(page).to have_current_path(review_page2) | |
# create_opinion | |
# expect(page).to have_current_path(success_page) | |
puts "\n\nopinion -> store -> opinion" | |
puts "[deveria estar na: home ] current_path #{page.current_path}" | |
click_link('', href: review_page) | |
puts "[deveria estar na: opinions/#{sale_item.id}/] current_path #{page.current_path}" | |
create_opinion | |
puts "[deveria estar na: home ] current_path #{page.current_path}" | |
click_link('', href: store_review_page) | |
puts "[deveria estar na: store_reviews/] current_path #{page.current_path}" | |
create_store_review | |
puts "[deveria estar na: opinions/#{sale_item2.id}/] current_path #{page.current_path}" | |
create_opinion | |
puts "[deveria estar na: success/] current_path #{page.current_path}" | |
end | |
it 'success after store -> opinion -> opinion' do | |
# click_link('', href: store_review_page) | |
# expect(page).to have_current_path(store_review_page) | |
# create_store_review | |
# expect(page).to have_current_path(home_page) | |
# click_link('', href: review_page) | |
# expect(page).to have_current_path review_page | |
# create_opinion | |
# expect(page).to have_current_path(review_page2) | |
# create_opinion | |
# expect(page).to have_current_path(success_page) | |
puts "\n\nstore -> opinion -> opinion" | |
puts "[deveria estar na: home ] current_path #{page.current_path}" | |
click_link('', href: store_review_page) | |
puts "[deveria estar na: store_reviews/] current_path #{page.current_path}" | |
create_store_review | |
puts "[deveria estar na: home ] current_path #{page.current_path}" | |
click_link('', href: review_page) | |
puts "[deveria estar na: opinions/#{sale_item.id}/] current_path #{page.current_path}" | |
create_opinion | |
puts "[deveria estar na: opinions/#{sale_item2.id}/] current_path #{page.current_path}" | |
create_opinion | |
puts "[deveria estar na: success/] current_path #{page.current_path}" | |
end | |
end | |
def create_opinion | |
fill_in :opinion_text, with: Faker::Lorem.sentence(1) | |
find("input#opinion_rate_4", visible: false).trigger("click") | |
VCR.use_cassette('create_opinion_in_workflow') do | |
click_on 'Enviar avaliação' | |
end | |
end | |
def create_store_review | |
fill_in :store_review_text, with: Faker::Lorem.sentence(1) | |
find("input#store_review_rate_4", visible: false).trigger("click") | |
click_on 'Enviar avaliação' | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment