adherent 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/adherent/jcmenu.css +5 -0
- data/app/controllers/adherent/allpayments_controller.rb +1 -1
- data/app/controllers/adherent/application_controller.rb +12 -0
- data/app/controllers/adherent/members_controller.rb +6 -7
- data/app/controllers/adherent/payments_controller.rb +2 -2
- data/app/helpers/adherent/application_helper.rb +9 -5
- data/app/helpers/adherent/payments_helper.rb +2 -2
- data/app/models/adherent/member.rb +77 -9
- data/app/models/adherent/payment.rb +0 -10
- data/app/views/adherent/allpayments/_payment.html.haml +3 -2
- data/app/views/adherent/members/index.html.erb +7 -1
- data/app/views/adherent/payments/_payment.html.haml +3 -2
- data/app/views/adherent/payments/show.html.haml +2 -2
- data/lib/adherent/version.rb +2 -1
- data/spec/controllers/adherent/adhesions_controller_spec.rb +25 -57
- data/spec/controllers/adherent/allpayments_controller_spec.rb +4 -1
- data/spec/controllers/adherent/members_controller_spec.rb +33 -46
- data/spec/controllers/adherent/payments_controller_spec.rb +18 -31
- data/spec/dummy/log/development.log +21002 -0
- data/spec/dummy/log/test.log +135111 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8259f3fc885403b4eea8dd12964c2ffc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c35251b000451b1b9f7274e0ae471704 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d88c0d3362ebdb47849b797a3ec1b355 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ee6531726dfe6592fa84b42a420b6acd +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fca89522784c8592001dc314a2361344 +0 -0
- data/spec/features/adhesions_spec.rb +3 -9
- data/spec/features/coord_spec.rb +3 -5
- data/spec/features/js_spec.rb +17 -15
- data/spec/features/members_spec.rb +26 -46
- data/spec/features/payments_spec.rb +15 -39
- data/spec/features/reglements_spec.rb +25 -31
- data/spec/models/adherent/adhesion_spec.rb +18 -40
- data/spec/models/adherent/coord_spec.rb +12 -9
- data/spec/models/adherent/member_spec.rb +144 -92
- data/spec/models/adherent/payment_spec.rb +20 -99
- data/spec/models/adherent/reglement_spec.rb +1 -1
- data/spec/rails_helper.rb +2 -1
- data/spec/spec_helper.rb +1 -0
- metadata +1 -6
- data/app/models/adherent/query_member.rb +0 -125
- data/spec/models/adherent/query_member_spec.rb +0 -169
- data/spec/support/fixtures.rb +0 -29
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,23 +1,17 @@
|
|
1
1
|
# coding utf-8
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
|
-
|
4
|
+
|
5
5
|
|
6
6
|
RSpec.configure do |c|
|
7
7
|
# c.filter = {wip:true}
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'ADHESIONS', :type => :feature do
|
11
|
-
|
12
|
-
|
11
|
+
fixtures :all
|
13
12
|
|
14
13
|
before(:each) do
|
15
|
-
|
16
|
-
@member= @members.first
|
17
|
-
end
|
18
|
-
|
19
|
-
after(:each) do
|
20
|
-
Adherent::Member.delete_all
|
14
|
+
@member= adherent_members(:Durand)
|
21
15
|
end
|
22
16
|
|
23
17
|
describe 'création d une adhésion' do
|
data/spec/features/coord_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'rails_helper'
|
2
|
-
require 'support/fixtures'
|
3
2
|
|
4
3
|
|
5
4
|
RSpec.configure do |c|
|
@@ -7,12 +6,11 @@ RSpec.configure do |c|
|
|
7
6
|
end
|
8
7
|
|
9
8
|
describe 'COORDONNEE', :type => :feature do
|
10
|
-
|
9
|
+
fixtures :all
|
11
10
|
|
12
11
|
|
13
|
-
before(:each) do
|
14
|
-
|
15
|
-
@member = @members.first
|
12
|
+
before(:each) do
|
13
|
+
@member = Adherent::Member.first
|
16
14
|
end
|
17
15
|
|
18
16
|
describe 'création de coordonnées' do
|
data/spec/features/js_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
4
|
require 'database_cleaner'
|
5
|
-
|
5
|
+
|
6
6
|
|
7
7
|
RSpec.configure do |config|
|
8
8
|
config.use_transactional_fixtures = false
|
@@ -27,16 +27,15 @@ end
|
|
27
27
|
module Adherent
|
28
28
|
|
29
29
|
describe 'javascript requests', :type => :feature do
|
30
|
-
|
30
|
+
fixtures :all
|
31
31
|
|
32
|
-
|
33
|
-
create_members
|
34
|
-
@member = @members.first
|
35
|
-
@domid = "#member_#{@member.id}"
|
36
|
-
end
|
32
|
+
|
37
33
|
|
38
34
|
describe 'delete member', js:true do
|
39
|
-
|
35
|
+
|
36
|
+
it 'supprimer un membre sans payment le supprime'do
|
37
|
+
@member = adherent_members(:Durand)
|
38
|
+
@domid = "#member_#{@member.id}"
|
40
39
|
visit adherent.members_path
|
41
40
|
within(@domid) do
|
42
41
|
click_link 'Supprimer'
|
@@ -44,14 +43,15 @@ describe 'javascript requests', :type => :feature do
|
|
44
43
|
alert = page.driver.browser.switch_to.alert
|
45
44
|
alert.accept
|
46
45
|
sleep 1
|
47
|
-
expect(Adherent::Member.count).to eq(
|
46
|
+
expect(Adherent::Member.count).to eq(2)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
50
|
describe 'delete adhesions', js:true do
|
52
51
|
|
53
|
-
it 'supprimer une adhésion dans la liste la supprime'
|
54
|
-
|
52
|
+
it 'supprimer une adhésion dans la liste la supprime' do
|
53
|
+
@member = adherent_members(:Dupont)
|
54
|
+
nb_adhs = @member.adhesions.count
|
55
55
|
adh = @member.adhesions.last
|
56
56
|
adh_id = "#adhesion_#{adh.id}"
|
57
57
|
visit adherent.member_adhesions_path(@member)
|
@@ -61,20 +61,22 @@ describe 'javascript requests', :type => :feature do
|
|
61
61
|
alert = page.driver.browser.switch_to.alert
|
62
62
|
alert.accept
|
63
63
|
sleep 1
|
64
|
-
expect(
|
64
|
+
expect(@member.adhesions(true).count).to eq(nb_adhs - 1)
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
68
68
|
|
69
|
-
describe 'delete payment', js:true
|
69
|
+
describe 'delete payment', js:true do
|
70
70
|
it 'détruit le payment' do
|
71
|
-
@
|
71
|
+
@member = adherent_members(:Dupont)
|
72
|
+
nb_pays = @member.payments.count
|
73
|
+
@pay = @member.payments.last
|
72
74
|
visit adherent.member_payment_path(@member, @pay)
|
73
75
|
click_link 'Supprimer'
|
74
76
|
alert = page.driver.browser.switch_to.alert
|
75
77
|
alert.accept
|
76
78
|
sleep 1
|
77
|
-
expect(
|
79
|
+
expect(@member.payments(true).count).to eq(nb_pays - 1)
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
@@ -1,85 +1,65 @@
|
|
1
1
|
# coding utf-8
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
|
-
|
4
|
+
|
5
5
|
|
6
6
|
RSpec.configure do |c|
|
7
7
|
# c.filter = {wip:true}
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'afficher tous les membres', :type => :feature do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
before(:each) do
|
15
|
-
create_members
|
16
|
-
end
|
11
|
+
fixtures :all
|
17
12
|
|
18
13
|
it 'affiche la liste' do
|
19
14
|
visit adherent.members_path
|
20
15
|
expect(page).to have_selector('h3', text:'Liste des membres')
|
21
16
|
end
|
22
17
|
|
23
|
-
it 'affiche le tableau des membres'
|
18
|
+
it 'affiche le tableau des membres' do
|
24
19
|
visit adherent.members_path
|
25
|
-
expect(page.all('table > tbody > tr').size).to eq(
|
20
|
+
expect(page.all('table > tbody > tr').size).to eq(Adherent::Member.count)
|
26
21
|
end
|
27
22
|
|
28
23
|
describe 'vérification des liens' do
|
29
24
|
|
30
25
|
before(:each) do
|
31
26
|
visit adherent.members_path
|
27
|
+
@m = Adherent::Member.first
|
32
28
|
end
|
33
29
|
|
34
|
-
it '
|
35
|
-
|
36
|
-
|
37
|
-
page.find("#coord_member_#{first_id}").click
|
38
|
-
end
|
39
|
-
expect(page.find('h3')).to have_content 'Saisie des coordonnées de le prénom NOM_0'
|
30
|
+
it 'sans coordonnées, renvoie vers la saisie des coordonnées' do
|
31
|
+
page.find("#coord_member_#{@m.id}").click
|
32
|
+
expect(page.find('h3')).to have_content "Saisie des coordonnées de #{@m.to_s}"
|
40
33
|
|
41
34
|
end
|
42
35
|
|
43
|
-
it '
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
page.find("#coord_member_#{first.id}").click
|
48
|
-
end
|
49
|
-
expect(page.find('h3')).to have_content 'Fiche coordonnées le prénom NOM_0'
|
36
|
+
it 'avec, les affiche' do
|
37
|
+
m = adherent_members(:Dupont)
|
38
|
+
page.find("#coord_member_#{m.id}").click
|
39
|
+
expect(page.find('h3')).to have_content "Saisie des coordonnées de #{m.to_s}"
|
50
40
|
end
|
51
41
|
|
52
|
-
it 'adhesion renvoie vers nouvelle adhésion'
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
expect(page.find('h3')).to have_content 'Renouvellement ou nouvelle adhésion pour le prénom NOM_0'
|
42
|
+
it 'adhesion renvoie vers nouvelle adhésion' do
|
43
|
+
m = adherent_members(:Durand)
|
44
|
+
page.find("#adhesion_member_#{m.id}").click
|
45
|
+
expect(page.find('h3')).to have_content "Renouvellement ou nouvelle adhésion pour #{m.to_s}"
|
58
46
|
end
|
59
47
|
|
60
48
|
it 'ou vers la liste des adhésions' do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
page.find("#adhesion_member_#{first.id}").click
|
65
|
-
end
|
66
|
-
expect(page.find('h3')).to have_content 'Historique des adhésions pour le prénom NOM_0'
|
49
|
+
m = adherent_members(:Dupont)
|
50
|
+
page.find("#adhesion_member_#{m.id}").click
|
51
|
+
expect(page.find('h3')).to have_content "Historique des adhésions pour #{m.to_s}"
|
67
52
|
end
|
68
53
|
|
69
54
|
it 'payement renvoie vers la vue index des payment' do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
expect(page.find('h3')).to have_content 'Historique des paiements reçus de le prénom NOM_0'
|
55
|
+
m = adherent_members(:Dupont)
|
56
|
+
page.find("#payment_member_#{m.id}").click
|
57
|
+
expect(page.find('h3')).to have_content "Historique des paiements reçus de #{m.to_s}"
|
75
58
|
|
76
59
|
end
|
77
60
|
|
78
|
-
it '
|
79
|
-
|
80
|
-
within(:css, 'table tbody tr:first') do
|
81
|
-
page.find("#edit_member_#{first_id}").click
|
82
|
-
end
|
61
|
+
it 'on peut éditer le membre' do
|
62
|
+
page.find("#edit_member_#{@m.id}").click
|
83
63
|
expect(page.find('h3')).to have_content 'Modification membre'
|
84
64
|
|
85
65
|
end
|
@@ -92,7 +72,7 @@ describe 'afficher tous les membres', :type => :feature do
|
|
92
72
|
|
93
73
|
end
|
94
74
|
|
95
|
-
describe 'create_members'
|
75
|
+
describe 'create_members' do
|
96
76
|
it 'remplir le form crée un membre et renvoie sur la page new_coord' do
|
97
77
|
visit adherent.new_member_path
|
98
78
|
fill_in 'Nom', with:'James'
|
@@ -101,7 +81,7 @@ describe 'afficher tous les membres', :type => :feature do
|
|
101
81
|
expect {click_button 'Créer le membre'}.to change {Adherent::Member.count}.by(1)
|
102
82
|
expect(page.find('h3').text).to eq('Saisie des coordonnées de Jessie JAMES')
|
103
83
|
end
|
104
|
-
|
84
|
+
|
105
85
|
|
106
86
|
end
|
107
87
|
|
@@ -1,25 +1,14 @@
|
|
1
1
|
# coding utf-8
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
|
-
require 'support/fixtures'
|
5
|
-
|
6
|
-
RSpec.configure do |c|
|
7
|
-
# c.filter = {wip:true}
|
8
|
-
end
|
9
4
|
|
10
5
|
describe 'PAYMENTS', :type => :feature do
|
11
|
-
|
6
|
+
fixtures :all
|
12
7
|
|
13
8
|
before(:each) do
|
14
|
-
|
15
|
-
@member= @members.first
|
16
|
-
@member.next_adhesion.save
|
9
|
+
@member= adherent_members(:Dupont)
|
17
10
|
end
|
18
11
|
|
19
|
-
after(:each) do
|
20
|
-
Adherent::Member.delete_all
|
21
|
-
end
|
22
|
-
|
23
12
|
describe 'création d un payment' do
|
24
13
|
|
25
14
|
it 'la page new payment affiche un form' do
|
@@ -37,38 +26,30 @@ describe 'PAYMENTS', :type => :feature do
|
|
37
26
|
expect(page.find('h3').text).to eq("Historique des paiements reçus de #{@member.to_s}")
|
38
27
|
end
|
39
28
|
|
40
|
-
|
41
29
|
end
|
42
30
|
|
43
31
|
describe 'la table des payments pour un membre' do
|
44
32
|
|
45
|
-
before(:each) do
|
46
|
-
|
47
|
-
@member.payments.create!(:date=>Date.today, :mode=>'CB', amount:876.54)
|
48
|
-
|
33
|
+
before(:each) do
|
49
34
|
visit adherent.member_payments_path @member
|
50
35
|
end
|
51
36
|
|
52
|
-
it 'affiche
|
53
|
-
|
54
|
-
expect(page.find('h3').text).to eq("Historique des paiements reçus de #{@member.to_s}")
|
37
|
+
it 'affiche une table des paiements' do
|
38
|
+
expect(page.find('h3').text).to eq("Historique des paiements reçus de #{@member.to_s}")
|
55
39
|
expect(page.all('table').size).to eq(1)
|
56
40
|
end
|
57
41
|
|
58
42
|
describe 'les icones d action' do
|
59
43
|
|
60
|
-
it 'cliquer sur imputation conduit à la vue new_règlement' do
|
61
|
-
|
44
|
+
it 'cliquer sur imputation conduit à la vue new_règlement' do
|
62
45
|
click_link 'Imputation'
|
63
|
-
expect(page.find('h3').text).to eq("Imputation du montant restant (
|
64
|
-
|
46
|
+
expect(page.find('h3').text).to eq("Imputation du montant restant (15,00 €) payé par #{@member.to_s}")
|
65
47
|
end
|
66
48
|
|
67
|
-
|
68
49
|
end
|
69
50
|
end
|
70
51
|
|
71
|
-
describe 'le formulaire pour un nouveau paiement'
|
52
|
+
describe 'le formulaire pour un nouveau paiement'do
|
72
53
|
|
73
54
|
before(:each) do
|
74
55
|
visit adherent.new_member_payment_path @member
|
@@ -79,21 +60,18 @@ describe 'PAYMENTS', :type => :feature do
|
|
79
60
|
end
|
80
61
|
|
81
62
|
it 'le montant doit être en format anglais' do
|
82
|
-
|
63
|
+
|
64
|
+
expect(page.find('input#payment_amount').value).to eq(@member.unpaid_amount.to_s)
|
83
65
|
end
|
84
66
|
|
85
67
|
end
|
86
68
|
|
87
|
-
describe 'l affichage d un paiement'
|
69
|
+
describe 'l affichage d un paiement' do
|
88
70
|
before(:each) do
|
89
|
-
@payment =
|
71
|
+
@payment = adherent_payments(:pay_1)
|
90
72
|
visit adherent.member_payment_path @member, @payment
|
91
73
|
end
|
92
74
|
|
93
|
-
after(:each) do
|
94
|
-
Adherent::Payment.delete_all
|
95
|
-
end
|
96
|
-
|
97
75
|
it 'affiche le titre' do
|
98
76
|
expect(page.find('h3').text).to eq("Détail d'un paiement")
|
99
77
|
end
|
@@ -105,10 +83,8 @@ describe 'PAYMENTS', :type => :feature do
|
|
105
83
|
end
|
106
84
|
|
107
85
|
it 'comprend une partie reçu pour impression' do
|
108
|
-
expect(page.find('.print').text).to have_content('Le trésorier')
|
109
|
-
end
|
86
|
+
expect(page.find('.print').text).to have_content('Le trésorier')
|
87
|
+
end
|
110
88
|
end
|
111
|
-
|
112
|
-
|
113
|
-
|
89
|
+
|
114
90
|
end
|
@@ -1,14 +1,9 @@
|
|
1
1
|
# coding utf-8
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
|
-
require 'support/fixtures'
|
5
|
-
|
6
|
-
RSpec.configure do |c|
|
7
|
-
# c.filter = {wip:true}
|
8
|
-
end
|
9
4
|
|
10
5
|
describe 'REGLEMENT', :type => :feature do
|
11
|
-
|
6
|
+
fixtures :all
|
12
7
|
|
13
8
|
def create_payment(montant)
|
14
9
|
visit adherent.new_member_payment_path(@member)
|
@@ -20,15 +15,13 @@ describe 'REGLEMENT', :type => :feature do
|
|
20
15
|
|
21
16
|
|
22
17
|
before(:each) do
|
23
|
-
|
24
|
-
@member= @members.first
|
25
|
-
@member.next_adhesion(50).save!
|
18
|
+
@member= adherent_members(:Dupont)
|
26
19
|
end
|
27
20
|
|
28
21
|
describe 'un membre avec une adhésion effectue un paiement du montant exact' do
|
29
22
|
|
30
23
|
it 'créer le payment change le nombre de payments' do
|
31
|
-
expect {create_payment(
|
24
|
+
expect {create_payment(26.66)}.to change {@member.payments(true).count}.by(1)
|
32
25
|
end
|
33
26
|
|
34
27
|
it 'créer le payment crée un règlement' do
|
@@ -42,10 +35,10 @@ describe 'REGLEMENT', :type => :feature do
|
|
42
35
|
|
43
36
|
end
|
44
37
|
|
45
|
-
describe 'le membre effectue un payment d un montant supérieur'
|
38
|
+
describe 'le membre effectue un payment d un montant supérieur' do
|
46
39
|
|
47
40
|
before(:each) do
|
48
|
-
create_payment(66)
|
41
|
+
create_payment(66.66)
|
49
42
|
end
|
50
43
|
|
51
44
|
it 'l adhésion du membre est réglée' do
|
@@ -53,15 +46,15 @@ describe 'REGLEMENT', :type => :feature do
|
|
53
46
|
end
|
54
47
|
|
55
48
|
it 'il reste un montant à imputer' do
|
56
|
-
expect(@member.payments.last.non_impute).to eq(
|
49
|
+
expect(@member.payments.last.non_impute).to eq(40)
|
57
50
|
end
|
58
51
|
|
59
52
|
end
|
60
53
|
|
61
|
-
describe 'le membre effectue un payment d un montant inférieur'
|
54
|
+
describe 'le membre effectue un payment d un montant inférieur' do
|
62
55
|
|
63
56
|
before(:each) do
|
64
|
-
create_payment(
|
57
|
+
create_payment(16.66)
|
65
58
|
end
|
66
59
|
|
67
60
|
it 'l adhésion du membre est réglée' do
|
@@ -69,20 +62,17 @@ describe 'REGLEMENT', :type => :feature do
|
|
69
62
|
end
|
70
63
|
|
71
64
|
it 'il reste un montant à imputer' do
|
72
|
-
expect(@member.unpaid_amount).to eq(
|
65
|
+
expect(@member.unpaid_amount).to eq(10)
|
73
66
|
end
|
74
67
|
|
75
68
|
end
|
76
69
|
|
77
70
|
describe 'imputation sur d autres adhésions' do
|
78
|
-
|
79
71
|
|
80
72
|
before(:each) do
|
81
|
-
create_payment(
|
73
|
+
create_payment(46.66)
|
82
74
|
@pay = @member.payments.last
|
83
|
-
@
|
84
|
-
@member2.next_adhesion(49).save
|
85
|
-
@members.third.next_adhesion(27).save
|
75
|
+
@nb_regs = Adherent::Reglement.count
|
86
76
|
visit adherent.new_payment_reglement_path(@pay)
|
87
77
|
end
|
88
78
|
|
@@ -90,7 +80,7 @@ describe 'REGLEMENT', :type => :feature do
|
|
90
80
|
# l'être pour les 30 restants sur les deux autres
|
91
81
|
it 'on vérifie' do
|
92
82
|
expect(@member.unpaid_amount).to eq(0)
|
93
|
-
expect(@member.payments.last.non_impute).to eq(
|
83
|
+
expect(@member.payments.last.non_impute).to eq(20)
|
94
84
|
end
|
95
85
|
|
96
86
|
it 'la page new_reglement affiche un form' do
|
@@ -98,7 +88,7 @@ describe 'REGLEMENT', :type => :feature do
|
|
98
88
|
end
|
99
89
|
|
100
90
|
it 'le montant affiché est le montant restant' do
|
101
|
-
expect(page.find('#reglement_amount').value).to eq('
|
91
|
+
expect(page.find('#reglement_amount').value).to eq('20,00 €')
|
102
92
|
end
|
103
93
|
|
104
94
|
it 'le select propose les deux adhesions' do
|
@@ -108,35 +98,39 @@ describe 'REGLEMENT', :type => :feature do
|
|
108
98
|
describe 'on choisit une option et on valide' do
|
109
99
|
|
110
100
|
before(:each) do
|
111
|
-
select "#{
|
101
|
+
select "#{adherent_members(:Fidele).to_s} - 24,00 €", :from=>'Adhésion'
|
112
102
|
click_button 'Enregistrer'
|
113
103
|
end
|
114
104
|
|
105
|
+
# it 'on regarde' , focus:true do
|
106
|
+
# visit adherent.new_payment_reglement_path(@pay)
|
107
|
+
# expect(page).to have_content('Bonjour')
|
108
|
+
# end
|
109
|
+
|
115
110
|
it 'on revient à la page index des payements' do
|
116
111
|
expect(page.find('h3').text).to eq("Historique des paiements reçus de #{@member.to_s}")
|
117
112
|
end
|
118
113
|
|
119
114
|
it 'il y a maintenant 2 reglements' do
|
120
|
-
|
121
|
-
expect(regs.size).to eq(2)
|
115
|
+
expect(Adherent::Reglement.count).to eq(@nb_regs + 1)
|
122
116
|
end
|
123
117
|
|
124
|
-
it 'le premier appartenant à member et pour
|
118
|
+
it 'le premier appartenant à member et pour 26.66 €' do
|
125
119
|
arf = Adherent::Reglement.first
|
126
120
|
expect(arf.payment_id).to eq(@pay.id)
|
127
121
|
expect(arf.adhesion.member).to eq(@member)
|
128
|
-
expect(arf.amount).to eq(
|
122
|
+
expect(arf.amount).to eq(26.66)
|
129
123
|
end
|
130
124
|
|
131
125
|
it 'le deuxième règlement' do
|
132
126
|
arl = Adherent::Reglement.last
|
133
127
|
expect(arl.payment_id).to eq(@pay.id)
|
134
|
-
expect(arl.adhesion.member).to eq(
|
135
|
-
expect(arl.amount).to eq(
|
128
|
+
expect(arl.adhesion.member).to eq(adherent_members(:Fidele))
|
129
|
+
expect(arl.amount).to eq(20)
|
136
130
|
end
|
137
131
|
|
138
132
|
it 'le membre2 ne doit plus que 19 €' do
|
139
|
-
expect(
|
133
|
+
expect(adherent_members(:Fidele).unpaid_amount).to eq(30)
|
140
134
|
end
|
141
135
|
|
142
136
|
|
@@ -1,21 +1,20 @@
|
|
1
1
|
# coding utf-8
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
|
-
|
4
|
+
|
5
5
|
|
6
6
|
RSpec.configure do |c|
|
7
7
|
# c.filter = {wip:true}
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'Adhesion', :type => :model do
|
11
|
-
|
11
|
+
|
12
|
+
|
13
|
+
fixtures :all
|
12
14
|
|
13
15
|
|
14
16
|
before(:each) do
|
15
|
-
@adh =
|
16
|
-
:to_date=>(Date.today.years_since(1)-1),
|
17
|
-
:amount=>19.27)
|
18
|
-
@adh.member_id = 1
|
17
|
+
@adh = adherent_adhesions(:adh_1)
|
19
18
|
end
|
20
19
|
|
21
20
|
describe 'validations' do
|
@@ -92,7 +91,7 @@ describe 'Adhesion', :type => :model do
|
|
92
91
|
|
93
92
|
it 'due est la différence entre amount et received' do
|
94
93
|
allow(@adh).to receive(:received).and_return 19
|
95
|
-
expect(@adh.due).to eq(
|
94
|
+
expect(@adh.due).to eq(7.66)
|
96
95
|
end
|
97
96
|
|
98
97
|
it 'is_paid indique si due vaut zero' do
|
@@ -109,42 +108,23 @@ describe 'Adhesion', :type => :model do
|
|
109
108
|
end
|
110
109
|
|
111
110
|
# on utilise des modèles réels car on veut tester la requête proprement dite
|
112
|
-
describe 'Ahesion.unpaid'
|
113
|
-
|
111
|
+
describe 'Ahesion.unpaid' do
|
114
112
|
|
115
113
|
before(:each) do
|
116
|
-
|
117
|
-
@
|
118
|
-
@a1 = @m1.adhesions.create!(amount:100, from_date:'01/08/2013', to_date:'31/08/2013')
|
119
|
-
@a2 = @m2.adhesions.create!(amount:50, from_date:'01/08/2013', to_date:'31/08/2013')
|
120
|
-
@m2.payments.create!(date:Date.today, amount:40, mode:'CB')
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
after(:each) do
|
125
|
-
Adherent::Member.delete_all
|
114
|
+
@m3 = adherent_members(:Fidele)
|
115
|
+
@nb_unpaid = Adherent::Adhesion.unpaid.to_a.size
|
126
116
|
end
|
127
117
|
|
128
|
-
it '
|
129
|
-
|
130
|
-
expect(Adherent::Adhesion.unpaid.first.reglements_amount.to_i).to eq(0)
|
131
|
-
expect(Adherent::Adhesion.unpaid.last.reglements_amount.to_i).to eq(40)
|
118
|
+
it 'sait calculer le montant total du' do
|
119
|
+
expect(Adherent::Adhesion.unpaid.to_a.sum(&:amount)).to eq(76.66)
|
132
120
|
end
|
133
|
-
|
134
|
-
it '
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
expect(Adherent::Adhesion.unpaid.first.reglements_amount.to_i).to eq(40)
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'on paye la dernière' do
|
142
|
-
@m2.payments.create!(date:Date.today, amount:10, mode:'CB')
|
143
|
-
@m1.payments.create!(date:Date.today, amount:100, mode:'CB')
|
144
|
-
expect(Adherent::Adhesion.unpaid.to_a.size).to eq(0)
|
121
|
+
|
122
|
+
it 'un paiement suffisant pour une adhésion règle une adhésion' do
|
123
|
+
@m3.payments.create!(date:Date.today, amount:40, mode:'CB')
|
124
|
+
expect(Adherent::Adhesion.unpaid.to_a.size).to eq(@nb_unpaid - 1)
|
125
|
+
expect(Adherent::Adhesion.unpaid.to_a.sum(&:amount)).to eq(52.66) # celle de 24
|
145
126
|
end
|
146
|
-
|
147
|
-
|
127
|
+
|
148
128
|
end
|
149
129
|
|
150
130
|
describe 'next adh values' do
|
@@ -191,8 +171,6 @@ describe 'Adhesion', :type => :model do
|
|
191
171
|
|
192
172
|
describe 'add_reglement' do
|
193
173
|
|
194
|
-
before(:each) {@adh.save!}
|
195
|
-
|
196
174
|
it 'le montant imputé est plafonné' do
|
197
175
|
@adh.add_reglement(1, 50)
|
198
176
|
expect(@adh).to be_is_paid
|
@@ -201,7 +179,7 @@ describe 'Adhesion', :type => :model do
|
|
201
179
|
it 'le montant imputé est celui du payment' do
|
202
180
|
@adh.add_reglement(1, 10)
|
203
181
|
expect(@adh).not_to be_is_paid
|
204
|
-
expect(@adh.due).to eq(
|
182
|
+
expect(@adh.due).to eq(16.66)
|
205
183
|
end
|
206
184
|
|
207
185
|
it 'add_reglement renvoie un règlement' do
|
@@ -1,10 +1,12 @@
|
|
1
|
-
# coding utf-8
|
1
|
+
# coding utf-8
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
4
|
|
5
5
|
describe 'Coord', :type => :model do
|
6
|
+
fixtures :all
|
7
|
+
|
6
8
|
before(:each) do
|
7
|
-
@m =
|
9
|
+
@m = adherent_members(:Dupont)
|
8
10
|
end
|
9
11
|
|
10
12
|
it 'les coordonnées sont rattachées à un membre' do
|
@@ -15,12 +17,13 @@ describe 'Coord', :type => :model do
|
|
15
17
|
end
|
16
18
|
|
17
19
|
it 'coord est dépendant du membre' do
|
18
|
-
m
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
m
|
24
|
-
expect(
|
20
|
+
expect{@m.create_coord(city:'Lille', zip:59000)}.
|
21
|
+
to change{Adherent::Coord.count}.by 1
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'détruire le membre détruit ses coordonnées' do
|
25
|
+
m = adherent_members(:Durand)
|
26
|
+
expect{adherent_members(:Durand).destroy}.
|
27
|
+
to change{Adherent::Coord.count}.by -1
|
25
28
|
end
|
26
29
|
end
|