gaku 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -4
  3. data/VERSION +1 -1
  4. data/core/app/controllers/concerns/enrollments_controller.rb +1 -2
  5. data/core/app/controllers/gaku/contacts_controller.rb +3 -3
  6. data/core/app/controllers/gaku/notes_controller.rb +33 -24
  7. data/core/app/controllers/gaku/syllabuses_controller.rb +44 -16
  8. data/core/app/models/gaku/address.rb +1 -1
  9. data/core/app/models/gaku/class_group_enrollment.rb +4 -3
  10. data/core/app/models/gaku/contact.rb +2 -2
  11. data/core/app/models/gaku/grading_method_set.rb +1 -1
  12. data/core/app/views/gaku/class_groups/students/enroll_students.js.erb +6 -0
  13. data/core/app/views/gaku/contacts/_form_fields.html.slim +1 -1
  14. data/core/app/views/gaku/notes/create.js.erb +3 -3
  15. data/core/app/views/gaku/notes/destroy.js.erb +3 -3
  16. data/core/app/views/gaku/notes/edit.js.erb +1 -1
  17. data/core/app/views/gaku/notes/new.js.erb +1 -1
  18. data/core/app/views/gaku/notes/show.js.erb +1 -1
  19. data/core/app/views/gaku/notes/update.js.erb +2 -2
  20. data/core/app/views/gaku/syllabuses/_syllabus_fields.html.slim +2 -3
  21. data/core/app/views/gaku/syllabuses/_syllabuses.html.slim +1 -1
  22. data/core/app/views/gaku/syllabuses/create.js.erb +4 -3
  23. data/core/app/views/gaku/syllabuses/destroy.js.erb +1 -1
  24. data/core/app/views/gaku/syllabuses/{show.html.slim → edit.html.slim} +0 -0
  25. data/core/app/views/gaku/syllabuses/edit.js.erb +1 -1
  26. data/core/app/views/gaku/syllabuses/new.js.erb +1 -1
  27. data/core/app/views/gaku/syllabuses/update.js.erb +1 -1
  28. data/core/config/routes.rb +0 -8
  29. data/core/gaku_core.gemspec +15 -11
  30. data/core/lib/gaku/testing/factories/note_factory.rb +4 -0
  31. data/core/lib/gaku/testing/factories/syllabus_factory.rb +4 -0
  32. data/core/lib/gaku/testing/request_helpers.rb +5 -0
  33. data/core/spec/controllers/gaku/addresses_controller_spec.rb +1 -1
  34. data/core/spec/controllers/gaku/contacts_controller_spec.rb +83 -12
  35. data/core/spec/controllers/gaku/notes_controller_spec.rb +143 -0
  36. data/core/spec/controllers/gaku/syllabuses_controller_spec.rb +140 -0
  37. data/core/spec/requests/admin/achievements/achievements_spec.rb +1 -1
  38. data/core/spec/requests/admin/grading/grading_method_set_items_spec.rb +1 -1
  39. data/core/spec/requests/admin/grading/grading_method_sets_spec.rb +1 -1
  40. data/core/spec/requests/admin/grading/grading_methods_spec.rb +1 -1
  41. data/core/spec/requests/admin/roles_spec.rb +1 -1
  42. data/core/spec/requests/admin/school_years/school_years_spec.rb +1 -1
  43. data/core/spec/requests/admin/school_years/semesters_spec.rb +1 -1
  44. data/core/spec/requests/admin/schools/campuses/addresses_spec.rb +1 -1
  45. data/core/spec/requests/admin/schools/campuses/campuses_spec.rb +1 -1
  46. data/core/spec/requests/admin/schools/campuses/contacts_spec.rb +10 -22
  47. data/core/spec/requests/admin/schools/programs_spec.rb +1 -1
  48. data/core/spec/requests/admin/schools/school_levels_spec.rb +1 -1
  49. data/core/spec/requests/admin/schools/schools_spec.rb +1 -1
  50. data/core/spec/requests/admin/specialties_spec.rb +1 -1
  51. data/core/spec/requests/admin/templates_spec.rb +1 -1
  52. data/core/spec/requests/admin/types_and_methods/attendance_types_spec.rb +1 -1
  53. data/core/spec/requests/admin/types_and_methods/commute_method_types_spec.rb +1 -1
  54. data/core/spec/requests/admin/types_and_methods/contact_types_spec.rb +1 -1
  55. data/core/spec/requests/admin/types_and_methods/enrollment_statuses_spec.rb +1 -1
  56. data/core/spec/requests/admin/types_and_methods/states_spec.rb +1 -1
  57. data/core/spec/requests/admin/users_spec.rb +1 -1
  58. data/core/spec/requests/class_groups/class_groups_spec.rb +1 -1
  59. data/core/spec/requests/class_groups/notes_spec.rb +6 -13
  60. data/core/spec/requests/class_groups/semester_class_groups_spec.rb +1 -1
  61. data/core/spec/requests/course_groups/course_groups_spec.rb +1 -1
  62. data/core/spec/requests/courses/courses_spec.rb +1 -1
  63. data/core/spec/requests/courses/notes_spec.rb +6 -11
  64. data/core/spec/requests/courses/semester_courses_spec.rb +1 -1
  65. data/core/spec/requests/exams/exam_portions/attachments_spec.rb +1 -1
  66. data/core/spec/requests/exams/notes_spec.rb +6 -11
  67. data/core/spec/requests/students/achievements_spec.rb +1 -1
  68. data/core/spec/requests/students/contacts_spec.rb +7 -7
  69. data/core/spec/requests/students/guardians/contacts_spec.rb +9 -17
  70. data/core/spec/requests/students/notes_spec.rb +5 -9
  71. data/core/spec/requests/students/simple_grades_spec.rb +1 -1
  72. data/core/spec/requests/students/specialties_spec.rb +1 -1
  73. data/core/spec/requests/syllabuses/exams_spec.rb +5 -5
  74. data/core/spec/requests/syllabuses/notes_spec.rb +5 -10
  75. data/core/spec/requests/syllabuses/syllabuses_spec.rb +46 -85
  76. data/core/spec/requests/teachers/contacts_spec.rb +11 -19
  77. data/core/spec/requests/teachers/notes_spec.rb +5 -10
  78. data/core/spec/support/requests/shared_addresses_spec.rb +6 -2
  79. data/core/spec/support/requests/shared_contacts_spec.rb +19 -15
  80. data/core/spec/support/requests/shared_notes_spec.rb +36 -35
  81. data/gaku_dependencies.rb +1 -8
  82. metadata +9 -9
  83. data/core/app/controllers/gaku/assignments_controller.rb +0 -15
  84. data/core/spec/controllers/gaku/syllabuses/syllabuses_controller_spec.rb +0 -92
@@ -1,3 +1,3 @@
1
- $('#new-syllabus').html('<%= render_js_partial("form") %>').slide();
1
+ $('#new-syllabus').html('<%= j render("form") %>').slide();
2
2
  $('#new-syllabus-link').hide();
3
3
  $('.remote-form').enableValidations();
@@ -1,4 +1,4 @@
1
1
  $('#syllabus-modal').modal('hide');
2
2
  $('#syllabus-modal').remove();
3
3
  showNotice("<%= render_flash %>");
4
- $('tr.syllabus-<%= @syllabus.id %>').html('<%= render_js_partial("gaku/shared/fields/syllabus_fields", {syllabus: @syllabus}) %>');
4
+ $('tr.syllabus-<%= @syllabus.id %>').html('<%= j render("gaku/shared/fields/syllabus_fields", {syllabus: @syllabus}) %>');
@@ -171,14 +171,6 @@ Gaku::Core::Engine.routes.draw do
171
171
 
172
172
  end
173
173
 
174
- resources :contacts do
175
- member do
176
- post :make_primary
177
- get :soft_delete
178
- get :recovery
179
- end
180
- end
181
-
182
174
  resources :notes
183
175
  resources :course_enrollments, controller: 'students/course_enrollments'
184
176
  resources :class_group_enrollments, controller: 'students/class_group_enrollments'
@@ -21,20 +21,32 @@ Gem::Specification.new do |s|
21
21
  s.requirements << 'redis'
22
22
 
23
23
  s.add_dependency 'rails', '~> 4.0.0'
24
+ s.add_dependency 'coffee-rails', '~> 4.0.0'
25
+ s.add_dependency 'sass-rails', '~> 4.0.0'
26
+ s.add_dependency 'uglifier', '~> 1.3'
24
27
  s.add_dependency 'turbolinks'
25
28
 
29
+ s.add_dependency 'pg'
30
+
26
31
  s.add_dependency 'slim', '~> 2.0.1'
27
32
  s.add_dependency 'inherited_resources'
28
33
  s.add_dependency 'responders'
29
34
  s.add_dependency 'paper_trail', '3.0.0.beta1'
30
35
  s.add_dependency 'globalize3'
31
36
  s.add_dependency 'draper', '~> 1.0'
37
+ s.add_dependency 'paperclip'
38
+ s.add_dependency 'ransack', '~> 1.0'
39
+ s.add_dependency 'kaminari'
40
+
41
+ s.add_dependency 'devise', '~> 3.0.0'
42
+ s.add_dependency 'devise-i18n'
43
+ s.add_dependency 'cancan'
32
44
 
33
45
  s.add_dependency 'rails4_client_side_validations', '0.0.3'
34
46
  s.add_dependency 'gaku_forms', '0.1.5'
35
- s.add_dependency 'gaku_nested_forms', '~> 0.1.0'
47
+ s.add_dependency 'gaku_nested_forms', '0.1.0'
36
48
  s.add_dependency 'nested_form'
37
- s.add_dependency 'gaku_helpers'
49
+ s.add_dependency 'gaku_helpers', '0.0.7'
38
50
 
39
51
  s.add_dependency 'rails-i18n'
40
52
  s.add_dependency 'i18n-js'
@@ -48,20 +60,12 @@ Gem::Specification.new do |s|
48
60
  s.add_dependency 'bootstrap-sass'
49
61
  s.add_dependency 'bootstrap-datepicker-rails'
50
62
 
51
- s.add_dependency 'paperclip'
52
- s.add_dependency 'ransack', '~> 1.0'
53
- s.add_dependency 'kaminari'
54
-
55
- s.add_dependency 'devise', '~> 3.0.0'
56
- s.add_dependency 'devise-i18n'
57
- s.add_dependency 'cancan'
58
-
59
63
  #spreadsheet handling
60
64
  s.add_dependency 'roo'
61
65
  s.add_dependency 'gen_sheet'
62
66
  s.add_dependency 'thinreports-rails'
63
67
 
64
- s.add_dependency 'highline', '= 1.6.11'
68
+ s.add_dependency 'highline', '1.6.11'
65
69
  s.add_dependency 'rubyzip', '0.9.9'
66
70
 
67
71
  s.add_dependency 'sidekiq'
@@ -3,6 +3,10 @@ FactoryGirl.define do
3
3
  factory :note, class: Gaku::Note do
4
4
  title 'Excellent'
5
5
  content 'Excellent student'
6
+
7
+ factory :invalid_note do
8
+ title nil
9
+ end
6
10
  end
7
11
 
8
12
  end
@@ -5,6 +5,10 @@ FactoryGirl.define do
5
5
  code '12345'
6
6
  description 'Short description'
7
7
  credits 'Huge Credits'
8
+
9
+ factory :invalid_syllabus do
10
+ code nil
11
+ end
8
12
  end
9
13
 
10
14
  trait :with_exam do
@@ -52,6 +52,11 @@ module Gaku::Testing::RequestHelpers
52
52
  '.edit-link'
53
53
  end
54
54
 
55
+ def js_edit_link
56
+ '.js-edit-link'
57
+ end
58
+
59
+
55
60
  def recovery_link
56
61
  '.recovery-link'
57
62
  end
@@ -7,7 +7,7 @@ describe Gaku::AddressesController do
7
7
  let!(:student) { create(:student) }
8
8
  let!(:country) { create(:country, name: 'USA', iso: 'US') }
9
9
 
10
- context 'as admin' do
10
+ context 'as admin', type: :address do
11
11
  before { as :admin }
12
12
 
13
13
  context 'student' do
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Gaku::ContactsController do
4
4
 
5
- let(:contact_type) { create(:contact_type) }
5
+ let!(:contact_type) { create(:contact_type) }
6
6
  let(:contact) { create(:contact, contactable: student, contact_type: contact_type) }
7
7
  let(:invalid_contact) { create(:invalid_contact, contactable: student) }
8
8
  let!(:student) { create(:student) }
9
9
 
10
- context 'as admin' do
10
+ context 'as admin', type: :contact do
11
11
  before { as :admin }
12
12
 
13
13
  context 'js' do
@@ -17,6 +17,10 @@ describe Gaku::ContactsController do
17
17
 
18
18
  it { should respond_with 200 }
19
19
  it('assigns @contact') { expect(assigns(:contact)).to be_a_new(Gaku::Contact) }
20
+ it('assigns @contact_types') { expect(assigns(:contact_types)).to eq [contact_type] }
21
+ it('assigns @polymorphic_resource_name') { expect(assigns(:polymorphic_resource_name)).to eq 'student-contact' }
22
+ it('assigns @polymorphic_resource') { expect(assigns(:polymorphic_resource)).to eq student }
23
+ it('assigns @nested_resources') { expect(assigns(:nested_resources)).to eq [] }
20
24
  it('renders the :new template') { template? :new }
21
25
  end
22
26
 
@@ -41,6 +45,21 @@ describe Gaku::ContactsController do
41
45
  valid_js_create
42
46
  expect(assigns(:count)).to eq 1
43
47
  end
48
+
49
+ it 'assigns @polymorphic_resource_name' do
50
+ valid_js_create
51
+ expect(assigns(:polymorphic_resource_name)).to eq 'student-contact'
52
+ end
53
+
54
+ it 'assigns @polymorphic_resource' do
55
+ valid_js_create
56
+ expect(assigns(:polymorphic_resource)).to eq student
57
+ end
58
+
59
+ it 'assigns @nested_resources' do
60
+ valid_js_create
61
+ expect(assigns(:nested_resources)).to eq []
62
+ end
44
63
  end
45
64
 
46
65
  context 'with invalid attributes' do
@@ -71,6 +90,10 @@ describe Gaku::ContactsController do
71
90
 
72
91
  it { should respond_with 200 }
73
92
  it('assigns @contact') { expect(assigns(:contact)).to eq contact }
93
+ it('assigns @contact_types') { expect(assigns(:contact_types)).to eq [contact_type] }
94
+ it('assigns @polymorphic_resource_name') { expect(assigns(:polymorphic_resource_name)).to eq 'student-contact' }
95
+ it('assigns @polymorphic_resource') { expect(assigns(:polymorphic_resource)).to eq student }
96
+ it('assigns @nested_resources') { expect(assigns(:nested_resources)).to eq [] }
74
97
  it('renders the :edit template') { template? :edit }
75
98
  end
76
99
 
@@ -82,6 +105,9 @@ describe Gaku::ContactsController do
82
105
 
83
106
  it { should respond_with 200 }
84
107
  it('assigns @contact') { expect(assigns(:contact)).to eq contact }
108
+ it('assigns @polymorphic_resource_name') { expect(assigns(:polymorphic_resource_name)).to eq 'student-contact' }
109
+ it('assigns @polymorphic_resource') { expect(assigns(:polymorphic_resource)).to eq student }
110
+ it('assigns @nested_resources') { expect(assigns(:nested_resources)).to eq [] }
85
111
  it('sets flash') { flash_updated? }
86
112
  it "changes contact's attributes" do
87
113
  expect(contact.reload.data).to eq 'mobifon'
@@ -113,6 +139,21 @@ describe Gaku::ContactsController do
113
139
  end.to change(Gaku::Contact, :count).by(-1)
114
140
  end
115
141
 
142
+ it 'assigns @polymorphic_resource_name' do
143
+ js_delete
144
+ expect(assigns(:polymorphic_resource_name)).to eq 'student-contact'
145
+ end
146
+
147
+ it 'assigns @polymorphic_resource' do
148
+ js_delete
149
+ expect(assigns(:polymorphic_resource)).to eq student
150
+ end
151
+
152
+ it 'assigns @nested_resources' do
153
+ js_delete
154
+ expect(assigns(:nested_resources)).to eq []
155
+ end
156
+
116
157
  it 'decrements @count' do
117
158
  js_delete
118
159
  expect(assigns(:count)).to eq 0
@@ -126,48 +167,78 @@ describe Gaku::ContactsController do
126
167
 
127
168
 
128
169
  describe 'XHR PATCH #soft_delete' do
129
- let(:get_soft_delete) { gaku_js_patch :soft_delete, id: contact.id, student_id: student.id }
170
+ let(:js_get_soft_delete) { gaku_js_patch :soft_delete, id: contact.id, student_id: student.id }
130
171
 
131
172
  it 'redirects' do
132
- get_soft_delete
173
+ js_get_soft_delete
133
174
  should respond_with(200)
134
175
  end
135
176
 
136
177
  it 'assigns @contact' do
137
- get_soft_delete
178
+ js_get_soft_delete
138
179
  expect(assigns(:contact)).to eq contact
139
180
  end
140
181
 
182
+ it 'assigns @polymorphic_resource_name' do
183
+ js_get_soft_delete
184
+ expect(assigns(:polymorphic_resource_name)).to eq 'student-contact'
185
+ end
186
+
187
+ it 'assigns @polymorphic_resource' do
188
+ js_get_soft_delete
189
+ expect(assigns(:polymorphic_resource)).to eq student
190
+ end
191
+
192
+ it 'assigns @nested_resources' do
193
+ js_get_soft_delete
194
+ expect(assigns(:nested_resources)).to eq []
195
+ end
196
+
141
197
  it 'updates :deleted attribute' do
142
198
  expect do
143
- get_soft_delete
199
+ js_get_soft_delete
144
200
  contact.reload
145
201
  end.to change(contact, :deleted)
146
202
  end
147
203
  end
148
204
 
149
205
  describe 'XHR PATCH #recovery' do
150
- let(:get_recovery) { gaku_js_patch :recovery, id: contact.id, student_id: student.id }
206
+ let(:js_get_recovery) { gaku_js_patch :recovery, id: contact.id, student_id: student.id }
151
207
 
152
208
  it 'is successfull' do
153
- get_recovery
209
+ js_get_recovery
154
210
  should respond_with(200)
155
211
  end
156
212
 
157
213
  it 'assigns @contact' do
158
- get_recovery
214
+ js_get_recovery
159
215
  expect(assigns(:contact)).to eq contact
160
216
  end
161
217
 
218
+ it 'assigns @polymorphic_resource_name' do
219
+ js_get_recovery
220
+ expect(assigns(:polymorphic_resource_name)).to eq 'student-contact'
221
+ end
222
+
223
+ it 'assigns @polymorphic_resource' do
224
+ js_get_recovery
225
+ expect(assigns(:polymorphic_resource)).to eq student
226
+ end
227
+
228
+ it 'assigns @nested_resources' do
229
+ js_get_recovery
230
+ expect(assigns(:nested_resources)).to eq []
231
+ end
232
+
162
233
  it 'renders :recovery' do
163
- get_recovery
234
+ js_get_recovery
164
235
  should render_template :recovery
165
- end
236
+ end
166
237
 
167
238
  it 'updates :deleted attribute' do
168
239
  contact.soft_delete
169
240
  expect do
170
- get_recovery
241
+ js_get_recovery
171
242
  contact.reload
172
243
  end.to change(contact, :deleted)
173
244
  end
@@ -0,0 +1,143 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gaku::NotesController do
4
+
5
+ let(:note) { create(:note, notable: student) }
6
+ let(:invalid_note) { build(:invalid_note, notable: student) }
7
+ let!(:student) { create(:student) }
8
+
9
+ context 'as admin', type: :note do
10
+ before { as :admin }
11
+
12
+ context 'student' do
13
+
14
+ describe 'XHR GET #new' do
15
+ before { gaku_js_get :new, student_id: student.id }
16
+
17
+ it { should respond_with 200 }
18
+ it('assigns @note') { expect(assigns(:note)).to be_a_new(Gaku::Note) }
19
+ it('assigns @notable') { expect(assigns(:notable)).to eq student }
20
+ it('renders the :new template') { template? :new }
21
+ end
22
+
23
+ describe 'XHR POST #create' do
24
+ context 'with valid attributes' do
25
+ let(:valid_js_create) do
26
+ gaku_js_post :create, note: attributes_for(:note), student_id: student.id
27
+ end
28
+
29
+ it 'creates new note' do
30
+ expect do
31
+ expect do
32
+ valid_js_create
33
+ end.to change(Gaku::Note, :count).by(1)
34
+ end.to change(student.notes, :count).by(1)
35
+ end
36
+
37
+ it 'renders flash' do
38
+ valid_js_create
39
+ flash_created?
40
+ end
41
+
42
+ it 'sets @notable' do
43
+ valid_js_create
44
+ expect(assigns(:notable)).to eq student
45
+ end
46
+
47
+ it 'increments @count' do
48
+ valid_js_create
49
+ expect(assigns(:count)).to eq 1
50
+ end
51
+ end
52
+
53
+ context 'with invalid attributes' do
54
+ let(:invalid_js_create) do
55
+ gaku_js_post :create, note: attributes_for(:invalid_note), student_id: student.id
56
+ end
57
+
58
+ it 'does not save the new note' do
59
+ expect do
60
+ invalid_js_create
61
+ end.to_not change(Gaku::Note, :count)
62
+ end
63
+
64
+ it 're-renders the new method' do
65
+ invalid_js_create
66
+ template? :create
67
+ end
68
+
69
+ it "doesn't increment @count" do
70
+ invalid_js_create
71
+ expect(assigns(:count)).to eq 0
72
+ end
73
+ end
74
+ end
75
+
76
+ describe 'XHR GET #edit' do
77
+ before { gaku_js_get :edit, id: note.id, student_id: student.id }
78
+
79
+ it { should respond_with 200 }
80
+ it('assigns @note') { expect(assigns(:note)).to eq note }
81
+ it('assigns @notable') { expect(assigns(:notable)).to eq student }
82
+ it('renders the :edit template') { template? :edit }
83
+ end
84
+
85
+ describe 'PATCH #update' do
86
+ context 'with valid attributes' do
87
+ before do
88
+ gaku_js_patch :update, id: note.id, student_id: student.id, note: attributes_for(:note, title: 'mobifon')
89
+ end
90
+
91
+ it { should respond_with 200 }
92
+ it('assigns @note') { expect(assigns(:note)).to eq note }
93
+ it('assigns @notable') { expect(assigns(:notable)).to eq student }
94
+ it('sets flash') { flash_updated? }
95
+ it "changes note's attributes" do
96
+ expect(note.reload.title).to eq 'mobifon'
97
+ end
98
+ end
99
+
100
+ context 'with invalid attributes' do
101
+ before do
102
+ gaku_js_patch :update, id: note.id, student_id: student.id, note: attributes_for(:invalid_note, title: '')
103
+ end
104
+
105
+ it { should respond_with 200 }
106
+ it('assigns @note') { expect(assigns(:note)).to eq note }
107
+ it "does not change note's attributes" do
108
+ expect(note.reload.title).not_to eq ''
109
+ end
110
+ end
111
+ end
112
+
113
+ describe 'XHR DELETE #destroy' do
114
+
115
+ let(:js_delete) { gaku_js_delete :destroy, id: note.id, student_id: student.id }
116
+
117
+ it 'deletes the note' do
118
+ note
119
+ expect do
120
+ js_delete
121
+ end.to change(Gaku::Note, :count).by(-1)
122
+ end
123
+
124
+ it('assigns @notable') do
125
+ js_delete
126
+ expect(assigns(:notable)).to eq student
127
+ end
128
+
129
+ it 'decrements @count' do
130
+ js_delete
131
+ expect(assigns(:count)).to eq 0
132
+ end
133
+
134
+ it 'sets flash' do
135
+ js_delete
136
+ flash_destroyed?
137
+ end
138
+ end
139
+
140
+ end
141
+
142
+ end
143
+ end