34 | <% end %>
35 |
36 |
--------------------------------------------------------------------------------
/features/step_definitions/fee_steps.rb:
--------------------------------------------------------------------------------
1 | Given /^I have no fees$/ do
2 | Fee.delete_all
3 | end
4 |
5 | Given /^I (only )?have fees titled "?([^\"]*)"?$/ do |only, titles|
6 | Fee.delete_all if only
7 | titles.split(', ').each do |title|
8 | Fee.create(:from_account => title)
9 | end
10 | end
11 |
12 | Then /^I should have ([0-9]+) fees?$/ do |count|
13 | Fee.count.should == count.to_i
14 | end
15 |
16 | #cucumber generated
17 |
18 | Given /^I am a logged in refinery user$/ do
19 | pending # express the regexp above with the code you wish you had
20 | end
21 |
22 | Given /^I have role member$/ do
23 | pending # express the regexp above with the code you wish you had
24 | end
25 |
26 | When /^I go to the list of fees$/ do
27 | pending # express the regexp above with the code you wish you had
28 | end
29 |
30 | Then /^I should see "([^"]*)"$/ do |arg1|
31 | pending # express the regexp above with the code you wish you had
32 | end
33 |
34 | When /^I follow "([^"]*)"$/ do |arg1|
35 | pending # express the regexp above with the code you wish you had
36 | end
37 |
38 | When /^I fill in "([^"]*)" with "([^"]*)"$/ do |arg1, arg2|
39 | pending # express the regexp above with the code you wish you had
40 | end
41 |
42 | When /^I press "([^"]*)"$/ do |arg1|
43 | pending # express the regexp above with the code you wish you had
44 | end
--------------------------------------------------------------------------------
/features/manage_fees.feature:
--------------------------------------------------------------------------------
1 | @fees
2 | Feature: Fees
3 | In order to have membership fees
4 | As an member
5 | I want to see my fees
6 |
7 | Background:
8 | Given I am a logged in refinery user
9 | And I have role member
10 | And I have no fees
11 |
12 | @fees-list @list
13 | Scenario: Fees List
14 | Given I have fees titled UniqueTitleOne, UniqueTitleTwo
15 | When I go to the list of fees
16 | Then I should see "UniqueTitleOne"
17 | And I should see "UniqueTitleTwo"
18 |
19 | @fees-valid @valid
20 | Scenario: Create Valid Fee
21 | When I go to the list of fees
22 | And I follow "Add New Fee"
23 | And I fill in "From account" with "This is a test of the first string field"
24 | And I press "Save"
25 | Then I should see "'This is a test of the first string field' was successfully added."
26 | And I should have 1 fee
27 |
28 | @fees-invalid @invalid
29 | Scenario: Create Invalid Fee (without from)
30 | When I go to the list of fees
31 | And I follow "Add New Fee"
32 | And I press "Save"
33 | Then I should see "From can't be blank"
34 | And I should have 0 fees
35 |
36 | @fees-duplicate @duplicate
37 | Scenario: Create Duplicate Fee
38 | Given I only have fees titled UniqueTitleOne, UniqueTitleTwo
39 | When I go to the list of fees
40 | And I follow "Add New Fee"
41 | And I fill in "From" with "UniqueTitleTwo"
42 | And I press "Save"
43 | Then I should see "There were problems"
44 | And I should have 2 fees
45 |
--------------------------------------------------------------------------------
/app/controllers/admin/fees_controller.rb:
--------------------------------------------------------------------------------
1 | module Admin
2 | class FeesController < Admin::BaseController
3 | crudify :fee, :xhr_paging => true
4 |
5 | layout proc{ |c| c.request.xhr? ? false : 'admin' }
6 |
7 | def index
8 | @fees = params[:search] ? Fee.search(params[:search], params[:page], current_user) : Fee.mine(params[:page], current_user)
9 |
10 | render(:partial => 'fees') if request.xhr?
11 | end
12 |
13 | def show
14 | @fee = Fee.find_by_id(params[:id])
15 | @users = User.all
16 | end
17 |
18 | def pair
19 | unless current_user.has_role?(:superuser)
20 | flash[:error] = 'Bad, bad boy!'
21 | redirect_to :action => 'index'
22 | else
23 | if params[:fee]
24 | pfs = params[:fee]
25 | pfs.each do |id, vs|
26 | if params[:fee][id][:vs]
27 | fee = Fee.find(id)
28 | user = User.find_by_progressbar_uid(params[:fee][id][:vs])
29 | unless user.nil?
30 | fee.update_attribute(:vs, user.progressbar_uid)
31 | fee.update_attribute(:user_id, user.id)
32 | end
33 | end
34 | end
35 |
36 | flash[:notice] = 'Fees was updated. Thank You!'
37 | end
38 |
39 | redirect_to :action => 'unpaired'
40 | end
41 | end
42 |
43 | def paired
44 | if current_user.has_role?(:superuser)
45 | @fees = Fee.paired
46 | @fees = @fees.paginate({:page => params[:page]})
47 |
48 | render(request.xhr? ? {:partial => 'fees' } : {:action => 'index'})
49 | else
50 | redirect_to :action => 'index'
51 | end
52 | end
53 |
54 | def unpaired
55 | if current_user.has_role?(:superuser)
56 | @fees = Fee.unpaired
57 | @fees = @fees.paginate({:page => params[:page]})
58 |
59 | render(request.xhr? ? {:partial => 'fees' } : {:action => 'index'})
60 | else
61 | redirect_to :action => 'index'
62 | end
63 | end
64 | end
65 | end
--------------------------------------------------------------------------------