Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 13 files changed
  • 0 comments
  • 1 contributor
4 .rvmrc
... ... @@ -1 +1,3 @@
1   -rvm ruby-1.9.2-p180@scidea-schools
  1 +rvm_gemset_create_on_use_flag=1
  2 +rvm 1.9.2-p180
  3 +rvm --create use ruby-1.9.2-p180@scidea-schools
57 app/assets/stylesheets/scidea/admin/pages/schools/edit_user.css
... ... @@ -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; }
2  app/assets/stylesheets/scidea/pages/schools/user_profile.css
@@ -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; }
6 app/controllers/schools_controller.rb
@@ -7,12 +7,14 @@ def index
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
14 app/themes/scidea/sass/admin/pages/schools/edit_user.scss
... ... @@ -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   -}
6 app/themes/scidea/sass/pages/schools/user_profile.scss
... ... @@ -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";
5 app/views/admin/users/_school_edit.html.erb
... ... @@ -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 } %>
2  app/views/schools/_profile_form.html.erb
@@ -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">
3  config/initializers/schools_assets.rb
... ... @@ -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
2  lib/scidea/schools/engine.rb
@@ -6,7 +6,7 @@ module Schools
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') }
44 spec/controllers/schools_controller_spec.rb
... ... @@ -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
8 spec/spec_helper.rb
@@ -16,12 +16,12 @@
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 @@
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.
15 spec/support/controller_macros.rb
... ... @@ -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

No commit comments for this range

Something went wrong with that request. Please try again.