-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
136 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,19 @@ | ||
<h1>Administrators</h1> | ||
|
||
<table> | ||
<tr><th>Name</th><th>Full name</th><th>E-mail address</th><th>Parent</th></tr> | ||
<tr><th>Name</th><th></th><th>Full name</th><th></th><th>E-mail address</th><th></th><th>Parent</th><th></th></tr> | ||
<% for user in @users %> | ||
<tr> | ||
<td><%= link_to user.name, :action => 'show', | ||
:id => user.id %></td> | ||
<td><%= user.fullname %></td> | ||
<td><%= user.email %></td> | ||
<td><%= (User.find(user.parent_id)).name %></td> | ||
<td><%= link_to user.name, :action => 'show_admin', | ||
:id => user.id %></td><td> </td> | ||
<td><%= user.fullname %></td><td> </td> | ||
<td><%= user.email %></td><td> </td> | ||
<td><%= (User.find(user.parent_id)).name %></td><td> </td> | ||
</tr> | ||
<% end -%> | ||
</table> | ||
|
||
|
||
<hr/> | ||
<%= form_tag({:action => 'new_administrator'}, {:method => 'post'}) do %> | ||
|
||
<br> | ||
<%= text_field_tag('name', '', {'size' => 30}) %> | ||
| ||
<input type='submit' value='New Administrator'/> | ||
<% end %> | ||
<%= form_tag(new_user_path, method: :get) do %> | ||
<%= hidden_field_tag :role, "Administrator" %> | ||
<%= submit_tag("New Administrator")%> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
<h1>Super-Administrators</h1> | ||
|
||
<table> | ||
<tr><th>Name</th><th>Full name</th><th>E-mail address</th><th>Parent</th></tr> | ||
<tr><th>Name</th><th>Full name</th><th>E-mail address</th></tr> | ||
<% for user in @users %> | ||
<tr> | ||
<td><%= link_to user.name, :action => 'show', | ||
<td><%= link_to user.name, :action => 'show_super_admin', | ||
:id => user.id %></td> | ||
<td><%= user.fullname %></td> | ||
<td><%= user.email %></td> | ||
<td><%= (User.find(user.parent_id)).name %></td> | ||
</tr> | ||
<% end -%> | ||
</table> | ||
|
||
<hr/> | ||
<p><%= link_to 'New Super administrator', :action => 'new' %></p> | ||
There can be only One Super Administrator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<%= render :partial => 'show' %> | ||
<hr/> | ||
<p><%= link_to 'Edit', edit_user_path(@user) %> | | ||
<%= link_to 'Delete', {:action => 'remove_administrator', :id => @user}, | ||
:confirm => 'Delete this user?', :method => :post %> </p> | ||
|
||
<p><%= link_to 'Back', :action => 'list_administrators' %> to Administrators list</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= render :partial => 'show' %> | ||
<hr/> | ||
<p><%= link_to 'Edit', edit_user_path(@user) %> | ||
|
||
<p><%= link_to 'Back', :action => 'list_super_administrators' %> to Super Administrators list</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<p><label for="user_institutions">Institution</label><br/> | ||
<%= collection_select('users',:institutions_id, Institution.all, :id, :name) %></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddInstitutionToUsers < ActiveRecord::Migration | ||
def change | ||
add_column :users, :institutions_id, :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'spec_helper' | ||
require 'rails_helper' | ||
|
||
describe 'admin_controller' do | ||
let (:user){User.new(:id => 2, :name => 'admin1')} | ||
|
||
it 'has id 2' do | ||
user.id.should eql (2) | ||
end | ||
it 'is named admin1' do | ||
user.name.should eql ('admin1') | ||
end | ||
|
||
it 'should be a new record' do | ||
user.should be_new_record | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'rails/all' | ||
require 'app/controllers/admin_controller' | ||
|
||
class AdminControllerTest < ActiveSupport::TestCase | ||
|
||
|
||
test 'should redirect to new administrator page' do | ||
get :new_administrator | ||
assert_redirected_to :controller => :users, :action => :new | ||
end | ||
|
||
test 'should create new admin' do | ||
get :new_administrator | ||
@admin = PgUsersController.new(:id => 2, :name => "admin1", :role_id => 5) | ||
@admin.save | ||
assert_response | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
require 'user_controller' | ||
class UserControllerTest < ActionController::TestCase | ||
|
||
|
||
test "should save institution id" do | ||
institutionID = institution_id.new | ||
assert institution_id.save, 'Institution ID saved' | ||
end | ||
|
||
test "should create instituition id" do | ||
assert_difference('User.count') do | ||
post :create, admin: {institution: 'North Carolina State Univeristy'} | ||
end | ||
|
||
end |