adherent 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/adherent/jcmenu.css +5 -0
  3. data/app/controllers/adherent/allpayments_controller.rb +1 -1
  4. data/app/controllers/adherent/application_controller.rb +12 -0
  5. data/app/controllers/adherent/members_controller.rb +6 -7
  6. data/app/controllers/adherent/payments_controller.rb +2 -2
  7. data/app/helpers/adherent/application_helper.rb +9 -5
  8. data/app/helpers/adherent/payments_helper.rb +2 -2
  9. data/app/models/adherent/member.rb +77 -9
  10. data/app/models/adherent/payment.rb +0 -10
  11. data/app/views/adherent/allpayments/_payment.html.haml +3 -2
  12. data/app/views/adherent/members/index.html.erb +7 -1
  13. data/app/views/adherent/payments/_payment.html.haml +3 -2
  14. data/app/views/adherent/payments/show.html.haml +2 -2
  15. data/lib/adherent/version.rb +2 -1
  16. data/spec/controllers/adherent/adhesions_controller_spec.rb +25 -57
  17. data/spec/controllers/adherent/allpayments_controller_spec.rb +4 -1
  18. data/spec/controllers/adherent/members_controller_spec.rb +33 -46
  19. data/spec/controllers/adherent/payments_controller_spec.rb +18 -31
  20. data/spec/dummy/log/development.log +21002 -0
  21. data/spec/dummy/log/test.log +135111 -0
  22. data/spec/dummy/tmp/cache/assets/test/sprockets/8259f3fc885403b4eea8dd12964c2ffc +0 -0
  23. data/spec/dummy/tmp/cache/assets/test/sprockets/c35251b000451b1b9f7274e0ae471704 +0 -0
  24. data/spec/dummy/tmp/cache/assets/test/sprockets/d88c0d3362ebdb47849b797a3ec1b355 +0 -0
  25. data/spec/dummy/tmp/cache/assets/test/sprockets/ee6531726dfe6592fa84b42a420b6acd +0 -0
  26. data/spec/dummy/tmp/cache/assets/test/sprockets/fca89522784c8592001dc314a2361344 +0 -0
  27. data/spec/features/adhesions_spec.rb +3 -9
  28. data/spec/features/coord_spec.rb +3 -5
  29. data/spec/features/js_spec.rb +17 -15
  30. data/spec/features/members_spec.rb +26 -46
  31. data/spec/features/payments_spec.rb +15 -39
  32. data/spec/features/reglements_spec.rb +25 -31
  33. data/spec/models/adherent/adhesion_spec.rb +18 -40
  34. data/spec/models/adherent/coord_spec.rb +12 -9
  35. data/spec/models/adherent/member_spec.rb +144 -92
  36. data/spec/models/adherent/payment_spec.rb +20 -99
  37. data/spec/models/adherent/reglement_spec.rb +1 -1
  38. data/spec/rails_helper.rb +2 -1
  39. data/spec/spec_helper.rb +1 -0
  40. metadata +1 -6
  41. data/app/models/adherent/query_member.rb +0 -125
  42. data/spec/models/adherent/query_member_spec.rb +0 -169
  43. data/spec/support/fixtures.rb +0 -29
@@ -2,12 +2,18 @@
2
2
 
3
3
  require 'rails_helper'
4
4
 
5
+ RSpec.configure do |c|
6
+ # c.exclusion_filter = {js:true}
7
+ # c.filter = {wip:true}
8
+ end
9
+
5
10
  describe Adherent::MembersController, :type => :controller do
6
11
 
12
+ fixtures ['organisms', 'adherent/members']
13
+
7
14
  before(:each) do
8
- @routes = Adherent::Engine.routes
15
+ @routes = Adherent::Engine.routes
9
16
  end
10
-
11
17
 
12
18
  describe "GET index" do
13
19
 
@@ -18,7 +24,7 @@ describe Adherent::MembersController, :type => :controller do
18
24
 
19
25
 
20
26
  it "assigns all members as @members" do
21
- expect(Adherent::QueryMember).to receive(:query_members).and_return([1,2])
27
+ expect(Adherent::Member).to receive(:query_members).and_return([1,2])
22
28
  get :index
23
29
  expect(assigns(:members)).to eq([1,2])
24
30
  end
@@ -33,15 +39,10 @@ describe Adherent::MembersController, :type => :controller do
33
39
  end
34
40
 
35
41
  describe "GET show" do
36
- it 'appelle le membre' do
37
- expect(Adherent::Member).to receive(:find).with('999').and_return(double(Adherent::Member))
38
- get :show, {id:'999'}
39
- end
40
-
42
+
41
43
  it 'assigne le membre et rend la vue' do
42
- allow(Adherent::Member).to receive(:find).with('998').and_return(@m = double(Adherent::Member))
43
- get :show, {id:'998'}
44
- expect(assigns[:member]).to eq(@m)
44
+ get :show, {id:adherent_members(:Durand).to_param}
45
+ expect(assigns[:member]).to eq(adherent_members(:Durand))
45
46
  expect(response).to render_template('show')
46
47
  end
47
48
  end
@@ -57,15 +58,11 @@ describe Adherent::MembersController, :type => :controller do
57
58
  end
58
59
 
59
60
  describe "GET edit" do
60
- it 'appelle le membre' do
61
- expect(Adherent::Member).to receive(:find).with('999').and_return(double(Adherent::Member))
62
- get :edit, {id:'999'}
63
- end
64
61
 
62
+
65
63
  it 'assigne le membre et rend la vue' do
66
- allow(Adherent::Member).to receive(:find).with('998').and_return(@m = double(Adherent::Member))
67
- get :edit, {id:'998'}
68
- expect(assigns[:member]).to eq(@m)
64
+ get :edit, {id:adherent_members(:Durand).to_param}
65
+ expect(assigns[:member]).to eq(adherent_members(:Durand))
69
66
  expect(response).to render_template('edit')
70
67
  end
71
68
  end
@@ -73,10 +70,10 @@ describe Adherent::MembersController, :type => :controller do
73
70
  describe "POST create" do
74
71
 
75
72
  before(:each) do
76
- @attrib = {name:'Dupont', forname:'Jules', number:'A001'}
73
+ @attrib = {name:'Dupont', forname:'Jules', number:'A55'}
77
74
  end
78
75
 
79
- it 'redirige vers index en cas de succès' do
76
+ it 'redirige vers la saisie des coordonnées en cas de succès' do
80
77
  post :create, :member=>@attrib
81
78
  expect(response).to redirect_to(new_member_coord_url(assigns[:member]))
82
79
  end
@@ -91,7 +88,7 @@ describe Adherent::MembersController, :type => :controller do
91
88
  post :create, :member=>@attrib
92
89
  expect(assigns[:member].name).to eq('Dupont')
93
90
  expect(assigns[:member].forname).to eq('Jules')
94
- expect(assigns[:member].number).to eq('A001')
91
+ expect(assigns[:member].number).to eq('A55')
95
92
  end
96
93
 
97
94
  it 'on peut enregistrer une date' do
@@ -107,31 +104,23 @@ describe Adherent::MembersController, :type => :controller do
107
104
  describe "POST update" do
108
105
 
109
106
  before(:each) do
110
- @member = Adherent::Member.new(name:'Dupont',forname:'Jules', number:'A002')
111
- @member.organism_id = 1
112
- puts @member.errors.messages unless @member.valid?
113
- @member.save
114
- allow(Adherent::Member).to receive(:find).with(@member.to_param).
115
- and_return @member
107
+ @member = adherent_members(:Dupont)
116
108
  end
117
-
118
-
119
-
109
+
120
110
  it 'appelle update_attributes' do
121
- expect(@member).to receive(:update_attributes).with({'name'=>'Dalton'}).and_return true
122
111
  post :update, {id:@member.to_param, :member=>{:name=>'Dalton'} }
112
+ expect(@member.reload.name).to eq 'Dalton'
123
113
  end
124
114
 
125
115
  it 'redirige vers show en cas de succès' do
126
- # allow(@member).to receive(:update_attributes).and_return true
116
+ # allow(@member).to receive(:update_attributes).and_return true
127
117
  post :update, {id:@member.to_param, :member=>{:name=>'Dalton'} }
128
118
  expect(response).to redirect_to(member_url(@member))
129
119
  end
130
120
 
131
121
  it 'et vers la vue edit autrement' do
132
- allow(@member).to receive(:update_attributes).and_return false
133
- post :update, {id:@member.to_param, :member=>{:name=>'Dalton'} }
134
- expect(response).to render_template 'edit'
122
+ post :update, {id:@member.to_param, :member=>{:number=>'A002'} }
123
+ expect(response).to render_template 'edit'
135
124
  end
136
125
 
137
126
  it 'la variable @member est assignée' do
@@ -141,22 +130,20 @@ describe Adherent::MembersController, :type => :controller do
141
130
  end
142
131
  end
143
132
 
144
- describe "DELETE destroy" do
133
+ describe "DELETE destroy" do
145
134
 
146
135
  before(:each) do
147
- @member = double(Adherent::Member)
136
+ @member = adherent_members(:Dupont)
137
+ @nb_members = Adherent::Member.count
148
138
  end
149
139
 
150
- it 'trouve le member demandé' do
151
- allow(@member).to receive(:destroy)
152
- expect(Adherent::Member).to receive(:find).with(@member.to_param).and_return @member
153
-
154
- delete :destroy, {:id=>@member.to_param}
155
- end
140
+ it 'détruit le member demandé' do
141
+ delete :destroy, {:id=>@member.to_param}
142
+ expect(Adherent::Member.count).to eq(@nb_members-1)
143
+ expect {Adherent::Member.find(1)}.to raise_error(ActiveRecord::RecordNotFound)
144
+ end
156
145
 
157
- it 'le détruit et le redirige vers la vue index' do
158
- allow(Adherent::Member).to receive(:find).with(@member.to_param).and_return @member
159
- expect(@member).to receive(:destroy).and_return true
146
+ it 'et redirige vers la vue index' do
160
147
  delete :destroy, {:id=>@member.to_param}
161
148
  expect(response).to redirect_to members_url
162
149
  end
@@ -4,28 +4,25 @@ require 'rails_helper'
4
4
 
5
5
  describe Adherent::PaymentsController, :type => :controller do
6
6
 
7
+ fixtures :all
8
+
7
9
  before(:each) do
8
10
  @routes = Adherent::Engine.routes
9
- @member = double(Adherent::Member)
10
- allow(Adherent::Member).to receive(:find).with(@member.to_param).and_return @member
11
+ @member = adherent_members(:Dupont)
11
12
  allow(@controller).to receive(:guess_date).and_return Date.today
12
13
  end
13
14
 
14
15
 
15
16
  describe "GET index" do
16
-
17
+
17
18
  it 'rend la vue index' do
18
- allow(@member).to receive(:payments)
19
19
  get :index, member_id:@member.to_param
20
20
  expect(response).to render_template("index")
21
21
  end
22
-
23
22
 
24
23
  it "assigns all coords as @coords" do
25
- expect(@member).to receive(:payments).and_return [1,2]
26
24
  get :index, member_id:@member.to_param
27
- expect(assigns(:payments)).to eq([1,2])
28
-
25
+ expect(assigns(:payments)).to eq(@member.payments)
29
26
  end
30
27
  end
31
28
 
@@ -34,12 +31,9 @@ describe Adherent::PaymentsController, :type => :controller do
34
31
  describe 'GET new' do
35
32
 
36
33
  it 'assigne un payments et rend la vue new' do
37
-
38
- expect(@member).to receive(:payments).and_return(@ar = double(Arel))
39
- expect(@member).to receive(:unpaid_amount).and_return 57
40
- expect(@ar).to receive(:new).with(date:Date.today, amount:57).and_return(@pay = double(Adherent::Payment))
41
34
  get :new, member_id:@member.to_param
42
- expect(assigns[:payment]).to eq(@pay)
35
+ expect(assigns[:payment]).to be_a_new(Adherent::Payment)
36
+ expect(assigns[:payment].member_id).to eq @member.id
43
37
  expect(response).to render_template('new')
44
38
  end
45
39
 
@@ -53,40 +47,33 @@ describe Adherent::PaymentsController, :type => :controller do
53
47
  end
54
48
 
55
49
  it 'crée une nouvelle adhésion avec les params' do
56
- expect(@member).to receive(:payments).and_return(@ar = double(Arel))
57
- expect(@ar).to receive(:new).with(@attrib).and_return(@pay = double(Adherent::Payment))
58
- expect(@pay).to receive(:save).and_return true
59
- post :create, {member_id:@member.to_param, :payment=>@attrib}
50
+ expect {
51
+ post :create, {member_id:@member.to_param, :payment=>@attrib} }.
52
+ to change {Adherent::Payment.count}.by 1
60
53
 
61
54
  end
62
55
 
63
56
  it 'renvoie vers la vue des adhésions' do
64
- allow(@member).to receive(:payments).and_return(@ar = double(Arel))
65
- allow(@ar).to receive(:new).and_return(@pay = double(Adherent::Payment))
66
- allow(@pay).to receive(:save).and_return true
67
57
  post :create, {member_id:@member.to_param, :payment=>@attrib}
68
- expect(response).to redirect_to(member_payments_url(assigns[:member]))
58
+ expect(response).to redirect_to(member_payments_url(@member))
69
59
  end
70
60
 
71
61
  it 'et vers la vue new autrement' do
72
- allow(@member).to receive(:payments).and_return(@ar = double(Arel))
73
- allow(@ar).to receive(:new).and_return(@pay = double(Adherent::Payment))
74
- allow(@pay).to receive(:save).and_return false
75
- post :create, {member_id:@member.to_param, :payment=>@attrib}
62
+ post :create, {member_id:@member.to_param,
63
+ :payment=>{'mode'=>'CB', 'date'=>I18n.l(Date.today) } }
76
64
  expect(response).to render_template('new')
77
65
  end
78
66
 
79
67
 
80
68
  end
81
69
 
82
- describe "GET show" do
70
+ describe "GET show" do
83
71
 
84
72
  it 'rend la vue show' do
85
- @pay = double(Adherent::Payment)
86
- expect(@member).to receive(:payments).and_return(@ar = double(Arel))
87
- expect(@ar).to receive(:find_by_id).with(@pay.to_param).and_return @pay
88
- get :show, member_id:@member.to_param , id:@pay.to_param
89
- expect(assigns[:payment]).to eq(@pay)
73
+ m = adherent_members(:Fidele)
74
+ pay = adherent_payments(:pay_2)
75
+ get :show, member_id:m.to_param , id:pay.to_param
76
+ expect(assigns[:payment]).to eq(pay)
90
77
  expect(response).to render_template('show')
91
78
  end
92
79
  end