scidea-schools 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -1 +1,73 @@
1
- Scidea Schools Extension
1
+ # Scidea Schools
2
+
3
+ Adds school association and lookup to users of Scitent's Scidea LMS platform. This gem is only useful in the context of the proprietary Scidea platform.
4
+
5
+ ## Usage
6
+
7
+ 1. Add `scidea-schools` to your Scidea Gemfile:
8
+
9
+ ```
10
+ # Gemfile
11
+ gem 'requirejs-rails'
12
+ ```
13
+
14
+ 2. Add the installation migrations to your ``db/migrate/`` folder:
15
+
16
+ ```
17
+ rails g scidea:schools:migrations
18
+ ```
19
+
20
+ 3. Schools will appear in the registration form when there is an audience/profession called *Educator* and there exists at least one school record in the database.
21
+
22
+ ## Development Environment and Testing
23
+
24
+ The gem is configured to use rspec and cucumber tests. Because there are so many dependencies upon the Scidea core, rspec and cucumber have been configured to launch an instance of the core application with the plugin's resources tied in. The features and specs of the plugin, however, are the only ones executed when you run cucumber and rspec, respectively.
25
+
26
+ To set up your environment for testing, perform the following:
27
+
28
+ 1. In your local Scidea core instance, add the following line to the Gemfile:
29
+
30
+ ```
31
+ # Gemfile
32
+ gem 'scidea-schools', :path => 'LOCAL_PATH_TO_SCIDEA-SCHOOLS'
33
+ ```
34
+
35
+ 2. 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
+
37
+ ```
38
+ source 'http://rubygems.org'
39
+
40
+ gemspec
41
+
42
+ gem 'scidea', :path => 'LOCAL_PATH_TO_SCIDEA-CORE'
43
+
44
+ #from scidea core Gemfile:
45
+ gem 'rails', '= 3.1.3'
46
+
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
+ ```
56
+
57
+ 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
+
59
+ ## Compiling CSS and Inclusion in the Asset Pipeline
60
+
61
+ [SASS](https://github.com/nex3/sass) and [Compass](https://github.com/chriseppstein/compass) are configured such that SASS files under the ``app/themes/scidea`` directory are compiled to ``app/assets/stylesheets/scidea`` when you run ``compass compile``.
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``.
64
+
65
+ ## JS Modules
66
+
67
+ JS modules live in the ``app/assets/javascript`` directory. This puts them in the asset pipeline when the gem is inlcuded with Rails and the Scidea core.
68
+
69
+ To work with the core, they must be written as [RequireJS AMDs](http://requirejs.org/). In order for the modules to work in production mode and to be compiled during assets precompilation in the core, you must include them in the requirejs-rails configuration file, ``config/requirejs.yml``.
70
+
71
+ ----
72
+
73
+ Copyright 2012 Scitent, Inc. See the file MIT-LICENSE for terms.
@@ -49,5 +49,3 @@ a[href="#select-new-school"] { display: none; }
49
49
 
50
50
  #schools-initial-message { display: block; }
51
51
  .schools-not-found #schools-initial-message { display: none; }
52
-
53
- #admin-new-school { display: none; }
@@ -7,12 +7,14 @@ class SchoolsController < ApplicationController
7
7
  @selected_school = params[:new_school_id] ? School.where("id = ?", params[:new_school_id]).first : nil
8
8
  @schools = School.learner_form_search(params[:zipcode], @selected_school)
9
9
 
10
- render_success
10
+ render_success
11
11
  end
12
12
 
13
13
  def create
14
14
  @school = School.new params[:school]
15
-
15
+
16
+ @school.approved = current_user && current_user.is_admin?
17
+
16
18
  if @school && @school.save
17
19
  render :json => @school.to_client_model_json
18
20
  else
@@ -1,6 +1,2 @@
1
1
  @import "config";
2
- @import "../../components/schools";
3
-
4
- #admin-new-school {
5
- display: none;
6
- }
2
+ @import "../../components/schools";
@@ -31,7 +31,7 @@
31
31
 
32
32
  </ol>
33
33
  <p id="schools-initial-message" class="inline-hints">Provide your institution&rsquo;s zipcode before selecting an institution.</p>
34
- <p id="schools-not-found-message" class="inline-hints">No institutions were found for zipcode. Try another one or <a href="#select-new-school">use the new institution you added.</a><a href="#add-new-school">add a new institution.</a><%= link_to 'add a new institution.', new_admin_school_path, :id => "admin-new-school" %> </p>
34
+ <p id="schools-not-found-message" class="inline-hints">No institutions were found for zipcode. Try another one or <a href="#select-new-school">use the new institution you added.</a><a href="#add-new-school">add a new institution.</a> </p>
35
35
  </fieldset>
36
36
  <div id="new-school">
37
37
  <p id="new-school-actions" class="inline-hints">
@@ -1,6 +1,5 @@
1
1
  Phoenix::Application.configure do
2
- config.assets.precompile += ['scidea/admin/pages/schools/edit_user.css',
3
- 'scidea/admin/pages/schools/user_migrate.css',
2
+ config.assets.precompile += ['scidea/admin/pages/schools/user_migrate.css',
4
3
  'scidea/pages/schools/user_profile.css']
5
4
  end
6
5
 
@@ -6,7 +6,7 @@ module Scidea
6
6
  class Engine < ::Rails::Engine
7
7
 
8
8
  initializer "scidea.schools.register_view_callbacks" do
9
- Scidea::Plugins::Plugin.on(:admin_user_form_after_profile) { conditional_render('admin/users/school_edit') }
9
+ Scidea::Plugins::Plugin.on(:admin_user_form_after_profile) { conditional_render('users/school_edit') }
10
10
 
11
11
  Scidea::Plugins::Plugin.on(:registration_new_after_profile) { conditional_render('users/school_edit') }
12
12
  Scidea::Plugins::Plugin.on(:user_profile_form_after_profile) { conditional_render('users/school_edit') }
@@ -1,5 +1,5 @@
1
1
  module Scidea
2
2
  module Schools
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe SchoolsController do
4
+ let(:user) { Factory.create(:user) }
5
+ let(:admin) { Factory.create(:user_user_admin) }
6
+ let(:school) { mock_model(School).as_null_object }
7
+
8
+
9
+ describe "create" do
10
+ context "logged in as admin" do
11
+ login_scitent_admin
12
+
13
+ before do
14
+ School.stub(:new).and_return(school)
15
+ end
16
+
17
+ it "assigns a school" do
18
+ post :create, :id => "123"
19
+ assigns[:school].should eq(school)
20
+ end
21
+
22
+ it "calls approved=true" do
23
+ school.should_receive(:approved=).with(true)
24
+ post :create, :id => "123"
25
+ end
26
+ end
27
+
28
+ context "not logged in" do
29
+ before do
30
+ School.stub(:new).and_return(school)
31
+ end
32
+
33
+ it "assigns a school" do
34
+ post :create, :id => "123"
35
+ assigns[:school].should eq(school)
36
+ end
37
+
38
+ it "calls approved=false" do
39
+ school.should_receive(:approved=).with(nil)
40
+ post :create, :id => "123"
41
+ end
42
+ end
43
+ end
44
+ end
data/spec/spec_helper.rb CHANGED
@@ -16,12 +16,12 @@ require File.expand_path("../../features/support/seed_user_roles.rb", __FILE__)
16
16
 
17
17
  # Requires supporting files with custom matchers and macros, etc,
18
18
  # in ./support/ and its subdirectories.
19
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
19
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
20
20
 
21
21
  RSpec.configure do |config|
22
22
  config.mock_with :rspec
23
23
  config.use_transactional_fixtures = true
24
-
24
+
25
25
  config.before(:suite) do
26
26
  DatabaseCleaner.strategy = :transaction
27
27
  DatabaseCleaner.clean_with(:truncation)
@@ -39,6 +39,10 @@ RSpec.configure do |config|
39
39
  config.after(:suite) do
40
40
  ::SeedUserRoles.clean
41
41
  end
42
+
43
+ config.include Devise::TestHelpers, :type => :controller
44
+ config.include Devise::TestHelpers, :type => :view
45
+ config.extend ControllerMacros, :type => :controller
42
46
  end
43
47
 
44
48
  # load local factories which will be added to the factories from scidea.
@@ -0,0 +1,15 @@
1
+ module ControllerMacros
2
+ def login_scitent_admin
3
+ before(:each) do
4
+ @request.env["devise.mapping"] = Devise.mappings[:users]
5
+ sign_in Factory(:user_scitent_admin)
6
+ end
7
+ end
8
+
9
+ def login_learner
10
+ before(:each) do
11
+ @request.env["devise.mapping"] = Devise.mappings[:users]
12
+ sign_in Factory(:user_learner)
13
+ end
14
+ end
15
+ 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.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &9205380 !ruby/object:Gem::Requirement
16
+ requirement: &19952360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9205380
24
+ version_requirements: *19952360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bartt-ssl_requirement
27
- requirement: &9204760 !ruby/object:Gem::Requirement
27
+ requirement: &19951740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.3.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *9204760
35
+ version_requirements: *19951740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cancan
38
- requirement: &9204180 !ruby/object:Gem::Requirement
38
+ requirement: &19951220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *9204180
46
+ version_requirements: *19951220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: will_paginate
49
- requirement: &9203080 !ruby/object:Gem::Requirement
49
+ requirement: &19950120 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *9203080
57
+ version_requirements: *19950120
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sqlite3-ruby
60
- requirement: &9202520 !ruby/object:Gem::Requirement
60
+ requirement: &19949500 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *9202520
68
+ version_requirements: *19949500
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-rails
71
- requirement: &9201940 !ruby/object:Gem::Requirement
71
+ requirement: &19948920 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *9201940
79
+ version_requirements: *19948920
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: database_cleaner
82
- requirement: &9201420 !ruby/object:Gem::Requirement
82
+ requirement: &19948400 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *9201420
90
+ version_requirements: *19948400
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: shoulda
93
- requirement: &9200780 !ruby/object:Gem::Requirement
93
+ requirement: &19947760 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 3.0.0.beta
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *9200780
101
+ version_requirements: *19947760
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: factory_girl_rails
104
- requirement: &9200120 !ruby/object:Gem::Requirement
104
+ requirement: &19947180 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *9200120
112
+ version_requirements: *19947180
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: compass
115
- requirement: &9199240 !ruby/object:Gem::Requirement
115
+ requirement: &19946360 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *9199240
123
+ version_requirements: *19946360
124
124
  description: Schools augments user's profiles with an associated school, along with
125
125
  interfaces for adding new schools at runtime. Administrators can manage schools
126
126
  and modify learner's schools.
@@ -137,7 +137,6 @@ files:
137
137
  - app/helpers/schools_helper.rb
138
138
  - app/views/layouts/application.html.erb
139
139
  - app/views/users/_school_edit.html.erb
140
- - app/views/admin/users/_school_edit.html.erb
141
140
  - app/views/admin/users/_profile_show_school.html.erb
142
141
  - app/views/admin/schools/_form.html.erb
143
142
  - app/views/admin/schools/show.html.erb
@@ -154,14 +153,12 @@ files:
154
153
  - app/views/schools/_profile_form.html.erb
155
154
  - app/themes/global_sass/_mixins.scss
156
155
  - app/themes/scidea/sass/components/_schools.scss
157
- - app/themes/scidea/sass/admin/pages/schools/edit_user.scss
158
156
  - app/themes/scidea/sass/admin/pages/schools/user_migrate.scss
159
157
  - app/themes/scidea/sass/_config.scss
160
158
  - app/themes/scidea/sass/pages/schools/user_profile.scss
161
159
  - app/models/school.rb
162
160
  - app/assets/javascripts/backbone_apps/school_selector.js
163
161
  - app/assets/javascripts/backbone_apps/models/school.js
164
- - app/assets/stylesheets/scidea/admin/pages/schools/edit_user.css
165
162
  - app/assets/stylesheets/scidea/admin/pages/schools/user_migrate.css
166
163
  - app/assets/stylesheets/scidea/pages/schools/user_profile.css
167
164
  - lib/scidea/schools.rb
@@ -212,9 +209,11 @@ files:
212
209
  - qunit/tests/backbone_apps/school_selector.js
213
210
  - qunit/test_runner.html.erb
214
211
  - qunit/html_fixtures/backbone_apps/_school_selector.html.erb
212
+ - spec/controllers/schools_controller_spec.rb
215
213
  - spec/routing/admin/admin_schools_routing_spec.rb
216
214
  - spec/routing/schools_routing_spec.rb
217
215
  - spec/factories/schools.rb
216
+ - spec/support/controller_macros.rb
218
217
  - spec/models/school_spec.rb
219
218
  - spec/models/profile_spec.rb
220
219
  - spec/models/ability_spec.rb
@@ -1,57 +0,0 @@
1
- #school-selection-fields { margin-bottom: .357em; }
2
- #school-selection-fields legend { display: block; width: 25%; float: left; padding: .35em 5px 0 0; font-size: 1em; }
3
- #school-selection-fields label { position: absolute !important; clip: rect(1px 1px 1px 1px); /* IE6, IE7 */ clip: rect(1px, 1px, 1px, 1px); }
4
- #school-selection-fields li { margin-bottom: .25em !important; }
5
- #school-selection-fields p.inline-hints { clear: both; padding-left: 0 !important; }
6
- .schools-found #school-selection-fields p.inline-hints { display: none; }
7
-
8
- #school-select-zipcode { width: 45px !important; min-width: 0 !important; margin-right: 5px; }
9
-
10
- #school-select-zipcode-input, #school-id-input { float: left; width: auto; }
11
-
12
- #main form #school-id-input p.inline-errors { padding: 0; margin: 3px 0 0; }
13
-
14
- #school-id { width: 200px; }
15
-
16
- #new-school { float: left; width: 72%; margin: 0; padding: 0 0 0 25%; }
17
- #new-school .inline-hints { padding-left: 0 !important; margin: 0 !important; }
18
-
19
- #new-school-form { display: none; background: #EFF4FF; border: 1px solid #A5B9C8; -moz-border-radius: 4px; -webkit-border-radius: 4px; -o-border-radius: 4px; -ms-border-radius: 4px; -khtml-border-radius: 4px; border-radius: 4px; padding: 1.07em 15px; width: 375px; }
20
- .ie7 #new-school-form { width: 400px; }
21
- #main form #new-school-form p.inline-errors { margin: 3px 0 0 100px; }
22
- #new-school-form .blockOverlay { background: #EFF4FF; filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50); opacity: 0.5; -moz-border-radius: 3px; -webkit-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; -khtml-border-radius: 3px; border-radius: 3px; }
23
- #new-school-form .blockMsg { border: 1px solid #aaa; -moz-box-shadow: rgba(0, 0, 0, 0.3) 2px 2px 5px; -webkit-box-shadow: rgba(0, 0, 0, 0.3) 2px 2px 5px; -o-box-shadow: rgba(0, 0, 0, 0.3) 2px 2px 5px; box-shadow: rgba(0, 0, 0, 0.3) 2px 2px 5px; -moz-border-radius: 4px; -webkit-border-radius: 4px; -o-border-radius: 4px; -ms-border-radius: 4px; -khtml-border-radius: 4px; border-radius: 4px; padding: 5px 10px 3px; color: #444; background: #fff; line-height: 1em; }
24
- .ie7 #new-school-form .blockMsg .text { position: relative; top: -3px; }
25
- #new-school-form .blockMsg .icon-loading { background: url('/images/scidea/icons/loading_barber_shop_pole.gif') 50% 40% no-repeat; width: 220px; display: -moz-inline-box; -moz-box-orient: vertical; display: inline-block; vertical-align: middle; *vertical-align: auto; height: 0px; padding: 20px 0 0; margin-left: 5px; }
26
- #new-school-form .blockMsg .icon-loading { *display: inline; }
27
- .adding-school #new-school-form, .editing-school #new-school-form { display: block; }
28
- #new-school-form ol { padding: 0 !important; margin-bottom: 0 !important; }
29
- #new-school-form li { margin-bottom: .714em; }
30
- #new-school-form input[type="text"] { background: #fff !important; border-color: #ccc; }
31
- #new-school-form label { width: 100px; }
32
- #new-school-form .buttons { padding-left: 105px !important; margin-bottom: 0 !important; }
33
-
34
- #school_submit { margin-right: 10px; }
35
-
36
- .schools-found #add-school { display: block; }
37
- #add-school, .adding-school #add-school, .new-school-exists #add-school { display: none; }
38
-
39
- .new-school-exists #edit-school { display: block; }
40
- #edit-school, .editing-school #edit-school, .schools-not-found #edit-school { display: none; }
41
-
42
- .schools-not-found #schools-not-found-message { display: block; }
43
- #schools-not-found-message, .adding-school #schools-not-found-message { display: none; }
44
-
45
- .new-school-exists a[href="#add-new-school"] { display: none; }
46
-
47
- a[href="#select-new-school"] { display: none; }
48
- .new-school-exists a[href="#select-new-school"] { display: inline; }
49
-
50
- #schools-initial-message { display: block; }
51
- .schools-not-found #schools-initial-message { display: none; }
52
-
53
- a[href="#add-new-school"] { display: none; }
54
-
55
- a[href="#select-new-school"] { display: none; }
56
-
57
- span #edit-school { display: none; }
@@ -1,14 +0,0 @@
1
- @import "config";
2
- @import "../../../components/schools";
3
-
4
- a[href="#add-new-school"] {
5
- display: none;
6
- }
7
-
8
- a[href="#select-new-school"] {
9
- display: none;
10
- }
11
-
12
- span #edit-school {
13
- display: none;
14
- }
@@ -1,5 +0,0 @@
1
- <% css do
2
- stylesheet_link_tag 'scidea/admin/pages/schools/edit_user'
3
- end %>
4
- <%= render :partial => 'schools/script_form', :locals => { :form => form } %>
5
- <%= render :partial => 'schools/profile_form', :locals => { :form => form } %>