Comparar commits
10 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| af5f33107e | |||
| bf6f70d59e | |||
| acfc8a9c75 | |||
| 66b949c40b | |||
| b713c9d286 | |||
| 629f8dee58 | |||
| 6c64042527 | |||
| 59fea573b8 | |||
| bb917fc7f0 | |||
| a26d2de1d9 |
@@ -5,7 +5,7 @@ require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
|
||||
feature "Back project" do
|
||||
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
|
||||
before do
|
||||
@project = Factory(:project, visible: true)
|
||||
@rewards = [
|
||||
@@ -30,6 +30,7 @@ feature "Back project" do
|
||||
find("a#login_with_mail").click
|
||||
verify_translations
|
||||
|
||||
fill_in 'user_name', :with => 'Lorem'
|
||||
fill_in 'user_email', :with => 'lorem@lorem.com'
|
||||
fill_in 'user_password', :with => '123lorem'
|
||||
fill_in 'user_password_confirmation', :with => '123lorem'
|
||||
@@ -55,60 +56,60 @@ feature "Back project" do
|
||||
# Had to add a sleep for the tests to pass on Travis-CI
|
||||
sleep 2
|
||||
find("#login").visible?.should be_true
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
scenario "As a user without credits, I want to back a project by entering the value and selecting no reward" do
|
||||
|
||||
|
||||
fake_login
|
||||
|
||||
|
||||
visit project_path(@project)
|
||||
verify_translations
|
||||
|
||||
|
||||
click_on "Quero apoiar este projeto"
|
||||
verify_translations
|
||||
current_path.should == new_project_backer_path(@project)
|
||||
|
||||
|
||||
fill_in "Com quanto você quer apoiar?", with: "10"
|
||||
|
||||
|
||||
click_on "Revisar e realizar pagamento"
|
||||
verify_translations
|
||||
current_path.should == review_project_backers_path(@project)
|
||||
page.should have_content("Você irá apoiar com R$ 10 e não quer nenhuma recompensa por seu apoio.")
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
scenario "As a user without credits, I want to back a project by clicking on the reward on the back project page, and pay using PayPal" do
|
||||
|
||||
|
||||
class FakeResponse
|
||||
def redirect_uri
|
||||
"http://www.paypal.com"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class FakeRequest
|
||||
def setup(*args)
|
||||
FakeResponse.new
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Configuration.create!(name: "paypal_username", value: "foobar")
|
||||
Configuration.create!(name: "paypal_password", value: "foobar")
|
||||
Configuration.create!(name: "paypal_signature", value: "foobar")
|
||||
Paypal::Express::Request.stubs(:new).returns(FakeRequest.new)
|
||||
Paypal::Express::Request.stubs(:setup).returns(FakeResponse.new)
|
||||
|
||||
|
||||
fake_login
|
||||
|
||||
|
||||
visit project_path(@project)
|
||||
verify_translations
|
||||
|
||||
|
||||
click_on "Quero apoiar este projeto"
|
||||
verify_translations
|
||||
current_path.should == new_project_backer_path(@project)
|
||||
|
||||
|
||||
fill_in "Com quanto você quer apoiar?", with: "10"
|
||||
|
||||
|
||||
choose "backer_reward_id_#{@rewards[2].id}"
|
||||
find("#backer_value")[:value].should == "30"
|
||||
choose "backer_reward_id_#{@rewards[1].id}"
|
||||
@@ -117,108 +118,110 @@ feature "Back project" do
|
||||
find("#backer_value")[:value].should == "30"
|
||||
choose "backer_reward_id_0"
|
||||
find("#backer_value")[:value].should == "30"
|
||||
|
||||
|
||||
fill_in "Com quanto você quer apoiar?", with: "10"
|
||||
choose "backer_reward_id_#{@rewards[1].id}"
|
||||
find("#backer_value")[:value].should == "20"
|
||||
|
||||
|
||||
Backer.count.should == 0
|
||||
|
||||
|
||||
click_on "Revisar e realizar pagamento"
|
||||
verify_translations
|
||||
current_path.should == review_project_backers_path(@project)
|
||||
page.should have_content("Você irá apoiar com R$ 20 e ganhará a seguinte recompensa: $20 reward")
|
||||
|
||||
|
||||
Backer.count.should == 1
|
||||
backer = Backer.first
|
||||
backer.payment_method.should == "MoIP"
|
||||
|
||||
|
||||
within "#international_payment" do
|
||||
|
||||
|
||||
click_on "Clique aqui"
|
||||
verify_translations
|
||||
find("#international_submit")[:disabled].should == "true"
|
||||
check "Eu li e estou de acordo com os termos de uso."
|
||||
find("#international_submit")[:disabled].should == "false"
|
||||
click_on "Efetuar pagamento pelo PayPal"
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
current_url.should match(/paypal\.com/)
|
||||
backer.reload
|
||||
backer.payment_method.should == "PayPal"
|
||||
|
||||
|
||||
visit thank_you_path
|
||||
verify_translations
|
||||
|
||||
|
||||
within 'head title' do
|
||||
page.should have_content("Muito obrigado")
|
||||
end
|
||||
|
||||
|
||||
within '#content_header' do
|
||||
within 'h1' do
|
||||
page.should have_content("Muito obrigado")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
page.should have_content "Você agora é parte do grupo que faz de tudo para o #{@project.name} acontecer."
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
scenario "As a user without credits, I want to back a project by clicking on a reward on the project page, and pay using MoIP", :now => true do
|
||||
|
||||
|
||||
MoIP::Client.stubs(:checkout).returns({"Token" => "foobar"})
|
||||
MoIP::Client.stubs(:moip_page).returns("http://www.moip.com.br")
|
||||
|
||||
|
||||
fake_login
|
||||
|
||||
|
||||
visit project_path(@project)
|
||||
verify_translations
|
||||
|
||||
|
||||
within "#rewards ul" do
|
||||
rewards = all("li.clickable")
|
||||
rewards[2].find("input[type=hidden]")[:value].should == "#{new_project_backer_path(@project)}/?reward_id=#{@rewards[2].id}"
|
||||
rewards[2].click
|
||||
end
|
||||
|
||||
|
||||
verify_translations
|
||||
|
||||
|
||||
find("#backer_reward_id_#{@rewards[2].id}")[:checked].should == "true"
|
||||
find("#backer_value")[:value].should == "30"
|
||||
|
||||
|
||||
Backer.count.should == 0
|
||||
|
||||
|
||||
click_on "Revisar e realizar pagamento"
|
||||
verify_translations
|
||||
current_path.should == review_project_backers_path(@project)
|
||||
page.should have_content("Você irá apoiar com R$ 30 e ganhará a seguinte recompensa: $30 reward")
|
||||
|
||||
|
||||
Backer.count.should == 1
|
||||
backer = Backer.first
|
||||
backer.payment_method.should == "MoIP"
|
||||
|
||||
|
||||
# Disabling jQuery mask, because we cannot test it with Capybara
|
||||
page.evaluate_script('jQuery.mask = function() { return true; }')
|
||||
|
||||
|
||||
fill_in "Nome completo", with: "Foo bar"
|
||||
fill_in "Email", with: "foo@bar.com"
|
||||
fill_in "CPF", with: "815.587.240-87"
|
||||
fill_in "CEP", with: "90050-004"
|
||||
|
||||
|
||||
# Sleep to wait for the loading of zip code data
|
||||
sleep 2
|
||||
|
||||
# sleep 2
|
||||
|
||||
fill_in "Logradouro", with: "Foo street"
|
||||
fill_in "Número", with: "1010"
|
||||
fill_in "Complemento", with: "10"
|
||||
fill_in "Bairro", with: "Foo bar"
|
||||
fill_in "Cidade", with: "Foo bar"
|
||||
select "Foo bar", from: "Estado"
|
||||
fill_in "Telefone celular", with: "(99)9999-9999"
|
||||
|
||||
|
||||
page.should have_css("#user_full_name.ok")
|
||||
page.should have_css("#user_email.ok")
|
||||
page.should have_css("#user_cpf.ok")
|
||||
page.should have_css("#user_address_zip_code.ok")
|
||||
# Skipping zip code verification because the loading is taking too long, and also the related fields are already filled
|
||||
# page.should have_css("#user_address_zip_code.ok")
|
||||
page.should have_css("#user_address_street.ok")
|
||||
page.should have_css("#user_address_number.ok")
|
||||
page.should have_css("#user_address_complement.ok")
|
||||
@@ -226,96 +229,96 @@ feature "Back project" do
|
||||
page.should have_css("#user_address_city.ok")
|
||||
page.should have_css("#user_address_state.ok")
|
||||
page.should have_css("#user_phone_number.ok")
|
||||
|
||||
|
||||
find("#user_submit")[:disabled].should == "true"
|
||||
check "Eu li e estou de acordo com os termos de uso."
|
||||
find("#user_submit")[:disabled].should == "false"
|
||||
click_on "Efetuar pagamento pelo MoIP"
|
||||
|
||||
|
||||
current_url.should match(/moip\.com\.br/)
|
||||
backer.reload
|
||||
backer.payment_method.should == "MoIP"
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
scenario "As a user with credits, I want to back a project using my credits" do
|
||||
|
||||
|
||||
fake_login
|
||||
user.update_attribute :credits, 10
|
||||
|
||||
|
||||
visit project_path(@project)
|
||||
verify_translations
|
||||
|
||||
|
||||
click_on "Quero apoiar este projeto"
|
||||
verify_translations
|
||||
current_path.should == new_project_backer_path(@project)
|
||||
|
||||
|
||||
fill_in "Com quanto você quer apoiar?", with: "10"
|
||||
check "Quero usar meus créditos para este apoio."
|
||||
|
||||
|
||||
Backer.count.should == 0
|
||||
|
||||
|
||||
click_on "Revisar e realizar pagamento"
|
||||
verify_translations
|
||||
|
||||
|
||||
Backer.count.should == 1
|
||||
backer = Backer.first
|
||||
backer.payment_method.should == "MoIP"
|
||||
|
||||
|
||||
current_path.should == review_project_backers_path(@project)
|
||||
page.should have_content("Você irá apoiar com R$ 10 e não quer nenhuma recompensa por seu apoio.")
|
||||
page.should have_content("Este apoio será pago com seus créditos. Após a confirmação, você ficará com um saldo de R$ 0 em créditos para apoiar outros projetos.")
|
||||
|
||||
|
||||
find("#user_submit")[:disabled].should == "true"
|
||||
check "Eu li e estou de acordo com os termos de uso."
|
||||
find("#user_submit")[:disabled].should == "false"
|
||||
click_on "Confirmar apoio com créditos"
|
||||
|
||||
|
||||
current_path.should == thank_you_path
|
||||
backer.reload
|
||||
backer.payment_method.should == "Credits"
|
||||
backer.confirmed.should == true
|
||||
user.reload
|
||||
user.credits.should == 0
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
scenario "As a user, I want to back a project anonymously" do
|
||||
|
||||
|
||||
fake_login
|
||||
user.update_attribute :credits, 10
|
||||
|
||||
|
||||
visit project_path(@project)
|
||||
verify_translations
|
||||
|
||||
|
||||
click_on "Quero apoiar este projeto"
|
||||
verify_translations
|
||||
|
||||
|
||||
fill_in "Com quanto você quer apoiar?", with: "10"
|
||||
check "Quero usar meus créditos para este apoio."
|
||||
|
||||
|
||||
check "Quero que meu apoio seja anônimo."
|
||||
|
||||
|
||||
Backer.count.should == 0
|
||||
|
||||
|
||||
click_on "Revisar e realizar pagamento"
|
||||
verify_translations
|
||||
|
||||
|
||||
Backer.count.should == 1
|
||||
backer = Backer.first
|
||||
backer.anonymous.should == true
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
scenario "I should not be able to access /thank_you if I not backed a project" do
|
||||
|
||||
|
||||
fake_login
|
||||
visit thank_you_path
|
||||
verify_translations
|
||||
|
||||
|
||||
current_path.should == root_path
|
||||
page.should have_css('.failure.wrapper')
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -39,6 +39,7 @@ feature "with login modal" do
|
||||
find("a.new_registration_link").click
|
||||
verify_translations
|
||||
|
||||
fill_in 'user_name', :with => 'Lorem'
|
||||
fill_in 'user_email', :with => 'lorem@lorem.com'
|
||||
fill_in 'user_password', :with => '123lorem'
|
||||
fill_in 'user_password_confirmation', :with => '123lorem'
|
||||
@@ -96,6 +97,7 @@ feature "with devise routes" do
|
||||
visit new_user_registration_path
|
||||
verify_translations
|
||||
|
||||
fill_in 'user_name', :with => 'Lorem'
|
||||
fill_in 'user_email', :with => 'lorem@lorem.com'
|
||||
fill_in 'user_password', :with => '123lorem'
|
||||
fill_in 'user_password_confirmation', :with => '123lorem'
|
||||
@@ -116,4 +118,4 @@ feature "with devise routes" do
|
||||
|
||||
ActionMailer::Base.deliveries.should_not be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,8 @@ class PaypalController < ApplicationController
|
||||
redirect_to paypal_response.redirect_uri
|
||||
#rescue Paypal::Exception::APIError => e
|
||||
# raise "Message: #{e.message}<br/>Response: #{e.response.inspect}<br/>Details: #{e.response.details.inspect}"
|
||||
rescue
|
||||
rescue Exception => e
|
||||
Exceptional.handle(e) rescue nil
|
||||
flash[:failure] = t('projects.pay.paypal_error')
|
||||
return redirect_to new_project_backer_path(backer.project)
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ class Backer < ActiveRecord::Base
|
||||
scope :pending, where(:confirmed => false)
|
||||
scope :display_notice, where(:display_notice => true)
|
||||
scope :can_refund, where(:can_refund => true)
|
||||
scope :within_refund_deadline, where("current_timestamp < (created_at + interval '180 days')")
|
||||
scope :within_refund_deadline, where("date(current_timestamp) <= date(created_at + interval '180 days')")
|
||||
after_create :define_key, :define_payment_method
|
||||
def define_key
|
||||
self.update_attribute :key, Digest::MD5.new.update("#{self.id}###{self.created_at}###{Kernel.rand}").to_s
|
||||
|
||||
@@ -22,7 +22,7 @@ class Reward < ActiveRecord::Base
|
||||
I18n.t('reward.display_remaining', :remaining => remaining, :maximum => maximum_backers)
|
||||
end
|
||||
def name
|
||||
"<div class='reward_minimum_value'>#{(minimum_value > 0 ? display_minimum+'+' : I18n.t('reward.dont_want'))}</div><div class='reward_description'>#{(description.html_safe)}</div>#{'<div class="sold_out">' + I18n.t('reward.sold_out') + '</div>' if sold_out?}<div class='clear'></div>".html_safe
|
||||
"<div class='reward_minimum_value'>#{minimum_value > 0 ? display_minimum+'+' : I18n.t('reward.dont_want')}</div><div class='reward_description'>#{h description}</div>#{'<div class="sold_out">' + I18n.t('reward.sold_out') + '</div>' if sold_out?}<div class='clear'></div>".html_safe
|
||||
end
|
||||
def display_minimum
|
||||
number_to_currency minimum_value, :unit => 'R$', :precision => 2, :delimiter => '.'
|
||||
|
||||
@@ -2,4 +2,4 @@ strong Você tem certeza que quer que seu apoio seja anônimo?
|
||||
| Deixar seu apoio público aumenta sua reputação e conta pontos para o nosso ranking de apoiadores.
|
||||
br
|
||||
br
|
||||
| Além disso, o valor do seu apoio não será divulgado para ninguém além do dono do projeto (que sempre saberá quem você é), mesmo que seu apoio seja público.
|
||||
| Além disso, o valor do seu apoio não será divulgado para ninguém além do dono do projeto. Somente o proponente terá acesso a essa informação, independente se o seu investimento seja público ou anônimo.
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
- unless @backer.credits
|
||||
= form.inputs do
|
||||
= form.input :full_name, :required => true, :as => :string
|
||||
= form.input :cpf, :required => true, :as => :string, :input_html => {:autocomplete => 'off'}
|
||||
= form.input :cpf, :as => :string, :input_html => {:autocomplete => 'off'}
|
||||
= form.input :email, :required => true, :as => :string
|
||||
= form.input :address_zip_code, :required => true, :as => :string, :input_html => {:autocomplete => 'off'}
|
||||
= form.input :address_street, :required => true, :as => :string
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
= content_for :title do
|
||||
= content_for :title do
|
||||
= t('.site_title')
|
||||
= content_for :content_header do
|
||||
h1=t('.title')
|
||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'login_with_email_form'}) do |f|
|
||||
= devise_error_messages!
|
||||
p.input
|
||||
= f.label :name
|
||||
= f.text_field :name
|
||||
p.input
|
||||
= f.label :email
|
||||
= f.text_field :email
|
||||
@@ -15,4 +18,4 @@
|
||||
= f.password_field :password_confirmation
|
||||
p.action
|
||||
= f.submit t('.submit')
|
||||
= render :partial => "devise/shared/links"
|
||||
= render :partial => "devise/shared/links"
|
||||
|
||||
@@ -31,7 +31,8 @@ module Reports
|
||||
'Bairro',
|
||||
'Cidade',
|
||||
'Estado',
|
||||
'CEP'
|
||||
'CEP',
|
||||
'Apoio anonimo?'
|
||||
]
|
||||
|
||||
@backers.each do |backer|
|
||||
@@ -55,7 +56,8 @@ module Reports
|
||||
backer.user.address_neighbourhood,
|
||||
backer.user.address_city,
|
||||
backer.user.address_state,
|
||||
backer.user.address_zip_code
|
||||
backer.user.address_zip_code,
|
||||
(backer.anonymous ? 'Sim' : 'Não')
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ module Reports
|
||||
(backer.created_at.strftime("%d/%m/%Y") if backer.created_at),
|
||||
backer.project.name,
|
||||
(backer.project.successful? ? 'Sim' : 'Não'),
|
||||
(backer.expires_at.strftime("%d/%m/%Y") if backer.expires_at),
|
||||
(backer.project.expires_at.strftime("%d/%m/%Y") if backer.project.expires_at),
|
||||
backer.project.category.name
|
||||
]
|
||||
end
|
||||
|
||||
@@ -4,8 +4,8 @@ everything_ok = function(){
|
||||
if($('#backer_credits').val() == "false"){
|
||||
if(!ok('#user_full_name'))
|
||||
all_ok = false
|
||||
if(!cpf_ok())
|
||||
all_ok = false
|
||||
//if(!cpf_ok())
|
||||
//all_ok = false
|
||||
if(!email_ok())
|
||||
all_ok = false
|
||||
if(!zip_code_ok())
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário