Skip to content
Browse files

spec acceptance: credits is passing

  • Loading branch information...
1 parent b397c72 commit d520add3b01adb78b6cf76be1b4d085404889f9a @josemarluedke josemarluedke committed May 10, 2012
View
28 acceptance/credits_spec.rb
@@ -9,38 +9,38 @@
fake_login
user.update_attribute :credits, 60
-
+
backers = [
Factory(:backer, user: user, confirmed: true, can_refund: true, requested_refund: false, refunded: false, value: 60, created_at: 181.days.ago),
- Factory(:backer, user: user, confirmed: true, can_refund: true, requested_refund: true, refunded: true, value: 1200, created_at: 180.days.ago),
+ Factory(:backer, user: user, confirmed: true, can_refund: true, requested_refund: true, refunded: false, value: 1200, created_at: 179.days.ago),
Factory(:backer, user: user, confirmed: true, can_refund: true, requested_refund: true, refunded: false, value: 120, created_at: 18.days.ago),
Factory(:backer, user: user, confirmed: true, can_refund: true, requested_refund: false, refunded: false, value: 10, created_at: 8.days.ago),
Factory(:backer, user: user, confirmed: true, can_refund: true, requested_refund: false, refunded: false, value: 60, created_at: 1.day.ago),
Factory(:backer, user: user, confirmed: true, can_refund: false, requested_refund: false, refunded: false, value: 40, created_at: 1.day.ago)
]
-
+
possible_backers = backers
possible_backers.slice!(0)
possible_backers.slice!(-1)
-
+
user.reload
-
+
click_link user.display_name
verify_translations
click_link 'Meus créditos'
verify_translations
- current_path.should == credits_path
+ current_path.should == user_path(user)
within 'head title' do
- page.should have_content("Meus créditos · #{I18n.t('site.name')}")
+ page.should have_content("#{user.display_name} · #{I18n.t('site.name')}")
end
user.credits.should == 60
find("#current_credits").should have_content(user.display_credits)
-
- rows = all("#credits table tbody tr")
+
+ rows = all("#user_credits table tbody tr")
rows.should have(4).items
-
+
# Testing the content of the whole table
rows.each_index do |index|
columns = rows[index].all("td")
@@ -58,18 +58,18 @@
end
columns[4].text.should == status
end
-
+
# Disabling javascript confirm, because we cannot test it with Capybara
page.evaluate_script('window.confirm = function() { return true; }')
-
+
# Requesting refund for the third row
within rows[2] do
click_on "Solicitar estorno"
verify_translations
column = rows[2].all("td")[4]
# Needed this sleep because have_content is not returning the right value and thus capybara does not know it has to way for the AJAX to finish
- sleep 2
- column.text.should == "Solicitado estorno"
+ sleep 3
+ column.text.should == "Pedido enviado com sucesso"
end
user.reload
user.credits.should == 50
View
2 app/controllers/users_controller.rb
@@ -46,7 +46,7 @@ def request_refund
status = e.message
end
- render :json => {:status => status}
+ render :json => {:status => status, :credits => current_user.reload.display_credits}
end
private
View
2 app/views/users/show.html.slim
@@ -84,7 +84,7 @@
- @credits.each do |credit|
tr[id="back_#{credit.id}"]
td.project_name
- = link_to credit.project.name, '#', :class => 'link_project'
+ = link_to credit.project.name, credit.project, :class => 'link_project'
td.date= I18n.l(credit.created_at.to_date)
td.value= credit.display_value
td.term= I18n.l(credit.refund_deadline.to_date)
View
1 public/javascripts/app/views/users/show.js
@@ -100,6 +100,7 @@ CATARSE.UsersShowView = Backbone.View.extend({
//notificationHtml += '</div>';
//notificationHtml +='</div>';
$('#creditsModal .modal-body').html(result['status']);
+ $('#current_credits').html(result['credits']);
$('#creditsModal').modal({
backdrop: true,
})

0 comments on commit d520add

Please sign in to comment.
Something went wrong with that request. Please try again.