-
Notifications
You must be signed in to change notification settings - Fork 22
/
budget_limits_spec.rb
52 lines (46 loc) · 1.96 KB
/
budget_limits_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'spec_helper'
#require 'ruby-debug'
feature "Budget limits", "" do
fixtures :all
scenario "Trying to approve too much money", :js => true do
sign_in_as_user(users(:tspmember))
visit request_path(requests(:wedge_for_party))
click_link "Edit"
page.should have_content "Edit request"
fill_in "request_expenses_attributes_0_approved_amount", :with => "120"
select "EUR", :from => "request_expenses_attributes_0_approved_currency"
click_button "Update request"
page.should have_content "request was successfully updated"
# Approval should fail
click_link "Action"
click_link "approve"
fill_in "notes", :with => "Not enough money, but let's try."
click_button "approve"
page.should have_content "Something went wrong. Not approved."
page.should have_content "approved amount exceeds the budget"
end
scenario "Approving the right amount", :js => true do
sign_in_as_user(users(:tspmember))
visit request_path(requests(:wedge_for_party))
click_link "Edit"
page.should have_content "Edit request"
fill_in "request_expenses_attributes_0_approved_amount", :with => "110"
select "EUR", :from => "request_expenses_attributes_0_approved_currency"
click_button "Update request"
page.should have_content "request was successfully updated"
# Approval should success
click_link "Action"
click_link "approve"
fill_in "notes", :with => "Not enough money, but let's try."
click_button "approve"
page.should have_content "Successfully approved"
page.should have_content "From submitted to approved"
end
scenario "Choosing the currency", :js => true do
sign_in_as_user(users(:tspmember))
visit request_path(requests(:wedge_for_party))
click_link "Edit"
page.should have_select "request_expenses_attributes_0_approved_currency", :with_options => %w(EUR)
page.should_not have_select "request_expenses_attributes_0_approved_currency", :with_options => %w(USD)
end
end