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
@@ -0,0 +1,140 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gaku::SyllabusesController do
4
+
5
+ let(:syllabus) { create(:syllabus) }
6
+ let(:invalid_syllabus) { create(:invalid_syllabus) }
7
+
8
+ context 'as admin' do
9
+ before { as :admin }
10
+
11
+ context 'html' do
12
+ describe 'GET #index' do
13
+ before do
14
+ syllabus
15
+ gaku_get :index
16
+ end
17
+
18
+ it { should respond_with 200 }
19
+ it('assigns @syllabuses') { expect(assigns(:syllabuses)).to eq [syllabus] }
20
+ it('assigns @count') { expect(assigns(:count)).to eq 1 }
21
+ it('renders :index template') { template? :index }
22
+ end
23
+ end
24
+
25
+ context 'js' do
26
+
27
+ describe 'XHR #new' do
28
+ before { gaku_js_get :new }
29
+
30
+ it { should respond_with 200 }
31
+ it('assigns @syllabus') { expect(assigns(:syllabus)).to be_a_new(Gaku::Syllabus) }
32
+ it('renders the :new template') { template? :new }
33
+ end
34
+
35
+ describe 'POST #create' do
36
+ context 'with valid attributes' do
37
+ let(:valid_js_create) do
38
+ gaku_js_post :create, syllabus: attributes_for(:syllabus)
39
+ end
40
+
41
+ it 'creates new syllabus' do
42
+ expect do
43
+ valid_js_create
44
+ end.to change(Gaku::Syllabus, :count).by(1)
45
+ end
46
+
47
+ it 'renders flash' do
48
+ valid_js_create
49
+ flash_created?
50
+ end
51
+
52
+ it 'increments @count' do
53
+ valid_js_create
54
+ expect(assigns(:count)).to eq 1
55
+ end
56
+ end
57
+
58
+ context 'with invalid attributes' do
59
+ let(:invalid_js_create) do
60
+ gaku_js_post :create, syllabus: attributes_for(:invalid_syllabus)
61
+ end
62
+
63
+ it 'does not save the new syllabus' do
64
+ expect do
65
+ invalid_js_create
66
+ end.to_not change(Gaku::Syllabus, :count)
67
+ end
68
+
69
+ it 're-renders the new method' do
70
+ invalid_js_create
71
+ template? :create
72
+ end
73
+
74
+ it "doesn't increment @count" do
75
+ invalid_js_create
76
+ expect(assigns(:count)).to eq 0
77
+ end
78
+ end
79
+ end
80
+
81
+ describe 'XHR #edit' do
82
+ before { gaku_js_get :edit, id: syllabus }
83
+
84
+ it { should respond_with 200 }
85
+ it('assigns @syllabus') { expect(assigns(:syllabus)).to eq syllabus }
86
+ it('renders the :edit template') { template? :edit }
87
+ end
88
+
89
+ describe 'PATCH #update' do
90
+ context 'with valid attributes' do
91
+ before do
92
+ gaku_js_patch :update, id: syllabus, syllabus: attributes_for(:syllabus, name: 'mobifon')
93
+ end
94
+
95
+ it { should respond_with 200 }
96
+ it('assigns @syllabus') { expect(assigns(:syllabus)).to eq syllabus }
97
+ it('sets flash') { flash_updated? }
98
+ it "changes syllabus's attributes" do
99
+ syllabus.reload
100
+ expect(syllabus.name).to eq 'mobifon'
101
+ end
102
+ end
103
+
104
+ context 'with invalid attributes' do
105
+ before do
106
+ gaku_js_patch :update, id: syllabus, syllabus: attributes_for(:invalid_syllabus, name: '')
107
+ end
108
+
109
+ it { should respond_with 200 }
110
+ it('assigns @syllabus') { expect(assigns(:syllabus)).to eq syllabus }
111
+
112
+ it "does not change syllabus's attributes" do
113
+ syllabus.reload
114
+ expect(syllabus.name).not_to eq ''
115
+ end
116
+ end
117
+ end
118
+
119
+ describe 'XHR DELETE #destroy' do
120
+ it 'deletes the syllabus' do
121
+ syllabus
122
+ expect do
123
+ gaku_js_delete :destroy, id: syllabus
124
+ end.to change(Gaku::Syllabus, :count).by(-1)
125
+ end
126
+
127
+ it 'decrements @count' do
128
+ gaku_js_delete :destroy, id: syllabus
129
+ expect(assigns(:count)).to eq 0
130
+ end
131
+
132
+ it 'sets flash' do
133
+ gaku_js_delete :destroy, id: syllabus
134
+ flash_destroyed?
135
+ end
136
+ end
137
+ end
138
+
139
+ end
140
+ end
@@ -37,7 +37,7 @@ describe 'Admin Achievements' do
37
37
 
38
38
  context '#edit ', js: true do
39
39
  before do
40
- within(table) { click edit_link }
40
+ within(table) { click js_edit_link }
41
41
  wait_until_visible modal
42
42
  end
43
43
 
@@ -49,7 +49,7 @@ describe 'Admin Grading Method Set Items' do
49
49
 
50
50
  context 'edit', js: true do
51
51
  before do
52
- within(table) { click edit_link }
52
+ within(table) { click js_edit_link }
53
53
  wait_until_visible modal
54
54
  end
55
55
 
@@ -39,7 +39,7 @@ describe 'Admin Grading Method Sets' do
39
39
 
40
40
  context 'edit', js: true do
41
41
  before do
42
- within(table) { click edit_link }
42
+ within(table) { click js_edit_link }
43
43
  wait_until_visible modal
44
44
  end
45
45
 
@@ -37,7 +37,7 @@ describe 'Admin Grading Methods' do
37
37
 
38
38
  context 'edit', js: true do
39
39
  before do
40
- within(table) { click edit_link }
40
+ within(table) { click js_edit_link }
41
41
  wait_until_visible modal
42
42
  end
43
43
 
@@ -41,7 +41,7 @@ describe 'Admin Roles' do
41
41
 
42
42
  context 'edit', js: true do
43
43
  before do
44
- within('#admin-roles-index tbody tr:nth-child(2)') { click edit_link }
44
+ within('#admin-roles-index tbody tr:nth-child(2)') { click js_edit_link }
45
45
  wait_until_visible modal
46
46
  end
47
47
 
@@ -64,7 +64,7 @@ describe 'Admin School Years' do
64
64
 
65
65
  context 'edit', js: true do
66
66
  before do
67
- within(table) { click edit_link }
67
+ within(table) { click js_edit_link }
68
68
  wait_until_visible modal
69
69
  end
70
70
 
@@ -80,7 +80,7 @@ describe 'Admin School Years Semesters' do
80
80
 
81
81
  context 'edit', js: true do
82
82
  before do
83
- within(table) { click edit_link }
83
+ within(table) { click js_edit_link }
84
84
  wait_until_visible modal
85
85
  end
86
86
 
@@ -65,7 +65,7 @@ describe 'Admin School Campuses Address' do
65
65
  context 'edit' do
66
66
  before do
67
67
  country_without_state
68
- click edit_link
68
+ click js_edit_link
69
69
  wait_until_visible modal
70
70
  end
71
71
 
@@ -47,7 +47,7 @@ describe 'Admin School Campuses' do
47
47
  end
48
48
  context 'edit' do
49
49
  before do
50
- within(table) { click edit_link }
50
+ within(table) { click js_edit_link }
51
51
  wait_until_visible modal
52
52
  end
53
53
 
@@ -3,19 +3,15 @@ require 'spec_helper'
3
3
  describe 'Admin School Campus Contact' do
4
4
 
5
5
  before { as :admin }
6
+ before(:all) { set_resource 'admin-school-campus-contact' }
6
7
 
7
8
  let(:school) { create(:school) }
8
- let(:contact_type) { create(:contact_type, name: 'Email') }
9
-
10
- before :all do
11
- set_resource 'admin-school-campus-contact'
12
- end
9
+ let!(:contact_type) { create(:contact_type, name: 'Email') }
13
10
 
14
11
  context 'new', js: true, type: 'contact' do
15
12
  before do
16
- contact_type
17
- @data = school.campuses.first
18
- visit gaku.admin_school_campus_path(school, school.campuses.first)
13
+ @resource = school.campuses.first
14
+ visit gaku.admin_school_campus_path(school, @resource)
19
15
  end
20
16
 
21
17
  it_behaves_like 'new contact'
@@ -27,19 +23,13 @@ describe 'Admin School Campus Contact' do
27
23
  before do
28
24
  @school = create(:school_with_one_contact)
29
25
  @school.reload
30
- @data = @school.campuses.first
26
+ @resource = @school.campuses.first
31
27
  end
32
28
 
33
29
  context 'edit' do
34
- before do
35
- contact_type
36
- visit gaku.admin_school_campus_path(@school, @school.campuses.first)
37
- end
38
-
30
+ before { visit gaku.admin_school_campus_path(@school, @resource) }
39
31
  it_behaves_like 'edit contact'
40
-
41
- it_behaves_like 'delete contact', @data
42
-
32
+ it_behaves_like 'delete contact', @resource
43
33
  end
44
34
  end
45
35
 
@@ -48,14 +38,12 @@ describe 'Admin School Campus Contact' do
48
38
  before do
49
39
  @school = create(:school_with_two_contacts)
50
40
  @school.reload
51
- @data = @school.campuses.first
52
- visit gaku.admin_school_campus_path(@school, @school.campuses.first)
41
+ @resource = @school.campuses.first
42
+ visit gaku.admin_school_campus_path(@school, @resource)
53
43
  end
54
44
 
55
45
  it_behaves_like 'primary contacts'
56
-
57
46
  end
58
-
59
-
60
47
  end
48
+
61
49
  end
@@ -75,7 +75,7 @@ describe 'Admin Program' do
75
75
  context 'edit' do
76
76
 
77
77
  before do
78
- within(table) { click edit_link }
78
+ within(table) { click js_edit_link }
79
79
  wait_until_visible modal
80
80
  end
81
81
 
@@ -68,7 +68,7 @@ describe 'Admin School Levels' do
68
68
  end
69
69
 
70
70
  it 'have no edit for school levels' do
71
- within(table) { click edit_link }
71
+ within(table) { click js_edit_link }
72
72
  page.should_not have_css 'a.add-school-level'
73
73
  end
74
74
 
@@ -59,7 +59,7 @@ describe 'Admin Schools' do
59
59
  context 'edit' do
60
60
 
61
61
  before do
62
- within(table) { click edit_link }
62
+ within(table) { click js_edit_link }
63
63
  wait_until_visible modal
64
64
  end
65
65
 
@@ -36,7 +36,7 @@ describe 'Admin Specialties' do
36
36
 
37
37
  context 'edit', js: true do
38
38
  before do
39
- within(table) { click edit_link }
39
+ within(table) { click js_edit_link }
40
40
  wait_until_visible modal
41
41
  end
42
42
 
@@ -51,7 +51,7 @@ describe 'Admin Templates' do
51
51
 
52
52
  context 'edit', js: true do
53
53
  before do
54
- within(table) { click edit_link }
54
+ within(table) { click js_edit_link }
55
55
  wait_until_visible modal
56
56
  end
57
57
 
@@ -42,7 +42,7 @@ describe 'Admin Attendance Types' do
42
42
 
43
43
  context '#edit ', js: true do
44
44
  before do
45
- within(table) { click edit_link }
45
+ within(table) { click js_edit_link }
46
46
  wait_until_visible modal
47
47
  end
48
48
 
@@ -38,7 +38,7 @@ describe 'Admin Commute Method Types' do
38
38
 
39
39
  context '#edit ', js: true do
40
40
  before do
41
- within(table) { click edit_link }
41
+ within(table) { click js_edit_link }
42
42
  wait_until_visible modal
43
43
  end
44
44
 
@@ -37,7 +37,7 @@ describe 'Admin Contact Types' do
37
37
 
38
38
  context 'edit', js: true do
39
39
  before do
40
- within(table) { click edit_link }
40
+ within(table) { click js_edit_link }
41
41
  wait_until_visible modal
42
42
  end
43
43
 
@@ -37,7 +37,7 @@ describe 'Admin Enrollment Statuses' do
37
37
 
38
38
  context 'edit', js: true do
39
39
  before do
40
- within(table) { click edit_link }
40
+ within(table) { click js_edit_link }
41
41
  wait_until_visible modal
42
42
  end
43
43
 
@@ -62,7 +62,7 @@ describe 'Admin States' do
62
62
  end
63
63
 
64
64
  context 'edits' do
65
- before { within(country_table) { click edit_link } }
65
+ before { within(country_table) { click js_edit_link } }
66
66
 
67
67
  it 'has validations' do
68
68
  fill_in 'state_name', with: ''
@@ -48,7 +48,7 @@ describe 'Admin Users' do
48
48
 
49
49
  context 'edit', js: true do
50
50
  before do
51
- within("#admin-users-index tbody tr#user-#{user.id}") { click edit_link }
51
+ within("#admin-users-index tbody tr#user-#{user.id}") { click js_edit_link }
52
52
  wait_until_visible modal
53
53
  end
54
54
 
@@ -57,7 +57,7 @@ describe 'ClassGroups' do
57
57
 
58
58
  context 'edit', js: true do
59
59
  before do
60
- click edit_link
60
+ click js_edit_link
61
61
  wait_until_visible modal
62
62
  end
63
63
 
@@ -3,19 +3,15 @@ require 'spec_helper'
3
3
  describe 'ClassGroup Notes' do
4
4
 
5
5
  before { as :admin }
6
+ before(:all) { set_resource 'class-group-note' }
6
7
 
7
8
  let(:class_group) { create(:class_group) }
8
- let(:note) { create(:note, notable: class_group) }
9
-
10
- before :all do
11
- set_resource 'class-group-note'
12
- end
9
+ let(:class_group_with_note) { create(:class_group, :with_note) }
13
10
 
14
11
  context 'new', type: 'note' do
15
12
  before do
16
- class_group
17
- visit gaku.class_group_path(class_group)
18
- @data = class_group
13
+ @resource = class_group
14
+ visit gaku.class_group_path(@resource)
19
15
  end
20
16
 
21
17
  it_behaves_like 'new note'
@@ -23,15 +19,12 @@ describe 'ClassGroup Notes' do
23
19
 
24
20
  context 'existing', js: true, type: 'note' do
25
21
  before do
26
- note
27
- visit gaku.class_group_path(class_group)
28
- @data = class_group
22
+ @resource = class_group_with_note
23
+ visit gaku.class_group_path(@resource)
29
24
  end
30
25
 
31
26
  it_behaves_like 'edit note'
32
-
33
27
  it_behaves_like 'delete note'
34
-
35
28
  end
36
29
 
37
30
  end