scidea-schools 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/README.md +4 -15
- data/app/controllers/admin/schools_controller.rb +10 -3
- data/app/models/school.rb +10 -0
- data/features/step_definitions/registration_steps.rb +0 -4
- data/lib/scidea/schools/version.rb +1 -1
- data/spec/controllers/admin/schools_controller_spec.rb +30 -0
- metadata +2 -1
data/CHANGELOG
CHANGED
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Adds school association and lookup to users of Scitent's Scidea LMS platform. Th
|
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
# Gemfile
|
|
11
|
-
gem '
|
|
11
|
+
gem 'scidea-schools'
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
2. Add the installation migrations to your ``db/migrate/`` folder:
|
|
@@ -32,7 +32,7 @@ To set up your environment for testing, perform the following:
|
|
|
32
32
|
gem 'scidea-schools', :path => 'LOCAL_PATH_TO_SCIDEA-SCHOOLS'
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
2.
|
|
35
|
+
2. Add the scidea gem to the scidea-schools Gemfile and add the path to your Scidea core instance. Then, copy the contents of the Scidea core Gemfile *after* ``gemspec``, and paste it to the end of the Gemfile in the scidea-schools code. When you run rspec/cucumber, they require this Gemfile, thus you need all of the gems that Scidea core requires as well.
|
|
36
36
|
|
|
37
37
|
```
|
|
38
38
|
source 'http://rubygems.org'
|
|
@@ -41,26 +41,15 @@ To set up your environment for testing, perform the following:
|
|
|
41
41
|
|
|
42
42
|
gem 'scidea', :path => 'LOCAL_PATH_TO_SCIDEA-CORE'
|
|
43
43
|
|
|
44
|
-
#
|
|
45
|
-
gem 'rails', '= 3.1.3'
|
|
44
|
+
# contents of scidea core Gemfile here....
|
|
46
45
|
|
|
47
|
-
# db
|
|
48
|
-
gem 'mysql2', '>= 0.3'
|
|
49
|
-
|
|
50
|
-
# authentication and authorization
|
|
51
|
-
gem 'devise', '< 2.0'
|
|
52
|
-
gem 'cancan'
|
|
53
|
-
|
|
54
|
-
... and so on
|
|
55
46
|
```
|
|
56
47
|
|
|
57
48
|
From scidea-schools, you can run ``rspec`` and ``cucumber``. Note that FactoryGirl factories from the Scidea core are included in the testing runtime and added to whatever you include in ``spec/factories``. The database configuration from the Scidea core will also be used. You must run all rake operations for that database in the context of the Scidea core folder. They will not work in the scidea-schools folder.
|
|
58
49
|
|
|
59
50
|
## Compiling CSS and Inclusion in the Asset Pipeline
|
|
60
51
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Because these stylesheets are added to the ``app/assets/stylesheets`` directory, they will be included in the Scidea core asset pipeline. However, because they are not ``scss`` files, Rails won't pick them up during the assets compile task. Therefore, any ``css`` file you add to ``app/assets/stylesheets`` must be included in the assets initializer: ``config/initializers/schools_assets.rb``.
|
|
52
|
+
Stylesheets from ``app/themes/scidea`` are added to the ``app/assets/stylesheets`` directory as a part of the asset pipeline. However, because they are not ``scss`` files, Rails won't pick them up during the assets compile task. Therefore, any ``css`` file you add to ``app/assets/stylesheets`` must be included in the assets initializer: ``config/initializers/schools_assets.rb``.
|
|
64
53
|
|
|
65
54
|
## JS Modules
|
|
66
55
|
|
|
@@ -68,9 +68,16 @@ module Admin
|
|
|
68
68
|
# DELETE /schools/1
|
|
69
69
|
def destroy
|
|
70
70
|
@school = School.where("id = ?", params[:id]).first
|
|
71
|
-
@school.destroy
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if @school.destroy
|
|
72
|
+
flash_message = { :success => "Educational institution was successfully deleted." }
|
|
73
|
+
else
|
|
74
|
+
if @school && @school.errors[:base] && @school.errors[:base].count > 0
|
|
75
|
+
flash_message = { :failure => @school.errors[:base].first }
|
|
76
|
+
else
|
|
77
|
+
flash_message = { :failure => "Educational Insitution could not be deleted" }
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
redirect_to(admin_schools_path, :flash => flash_message)
|
|
74
81
|
end
|
|
75
82
|
|
|
76
83
|
# GET /schools/1/migration/new
|
data/app/models/school.rb
CHANGED
|
@@ -14,6 +14,8 @@ class School < ActiveRecord::Base
|
|
|
14
14
|
|
|
15
15
|
validate :zipcode_formatting
|
|
16
16
|
validate :phone_formatting
|
|
17
|
+
|
|
18
|
+
before_destroy :do_not_delete_if_dependencies
|
|
17
19
|
|
|
18
20
|
ZIPCODE_PATTERN = /^[\d]{5}$/
|
|
19
21
|
|
|
@@ -89,5 +91,13 @@ class School < ActiveRecord::Base
|
|
|
89
91
|
def zipcode_formatting
|
|
90
92
|
errors.add(:zipcode, "must be five numbers") unless zipcode && zipcode.match(ZIPCODE_PATTERN)
|
|
91
93
|
end
|
|
94
|
+
|
|
95
|
+
def do_not_delete_if_dependencies
|
|
96
|
+
# if any users have this school, do not delete it
|
|
97
|
+
if self.profiles.count > 0
|
|
98
|
+
self.errors.add(:base, "Educational institution #{self.name} was not deleted because it is tied to user profiles. Before deleting #{self.name} use the migration feature to migrate these users to other educational institutions.")
|
|
99
|
+
return false
|
|
100
|
+
end
|
|
101
|
+
end
|
|
92
102
|
|
|
93
103
|
end
|
|
@@ -10,8 +10,4 @@ Given /^I fill in the core registration fields$/ do
|
|
|
10
10
|
step %{I fill in "user_password_confirmation" with "password"}
|
|
11
11
|
step %{I fill in "user_profile_attributes_first_name" with "Test"}
|
|
12
12
|
step %{I fill in "user_profile_attributes_last_name" with "Learner"}
|
|
13
|
-
step %{I select "Ms." from "user_profile_attributes_salutation"}
|
|
14
|
-
step %{I select "1980" from "user_profile_attributes_birthdate_1i"}
|
|
15
|
-
step %{I select "January" from "user_profile_attributes_birthdate_2i"}
|
|
16
|
-
step %{I select "1" from "user_profile_attributes_birthdate_3i"}
|
|
17
13
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Admin::SchoolsController do
|
|
4
|
+
let(:admin) { Factory.create(:user_user_admin) }
|
|
5
|
+
let(:school) { Factory.create :school }
|
|
6
|
+
|
|
7
|
+
describe "DELETE :destroy" do
|
|
8
|
+
context "school has a user" do
|
|
9
|
+
login_scitent_admin
|
|
10
|
+
|
|
11
|
+
before do
|
|
12
|
+
Factory :profile, :school => school
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "does not delete the school when it is tied to a profile" do
|
|
16
|
+
delete :destroy, :id => school.id
|
|
17
|
+
assigns(:school).should_not be_destroyed
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "school has no user" do
|
|
22
|
+
login_scitent_admin
|
|
23
|
+
|
|
24
|
+
it "does delete the school when it is not tied to a profile" do
|
|
25
|
+
delete :destroy, :id => school.id
|
|
26
|
+
assigns(:school).should be_destroyed
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scidea-schools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.6
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -99,6 +99,7 @@ files:
|
|
|
99
99
|
- qunit/tests/backbone_apps/school_selector.js
|
|
100
100
|
- qunit/test_runner.html.erb
|
|
101
101
|
- qunit/html_fixtures/backbone_apps/_school_selector.html.erb
|
|
102
|
+
- spec/controllers/admin/schools_controller_spec.rb
|
|
102
103
|
- spec/controllers/schools_controller_spec.rb
|
|
103
104
|
- spec/routing/admin/admin_schools_routing_spec.rb
|
|
104
105
|
- spec/routing/schools_routing_spec.rb
|