From 63701c824723cf1055bdd699ea505df575c33928 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Thu, 18 Aug 2016 18:22:57 -0500 Subject: [PATCH] admin views roughed in --- Guardfile | 28 +++--- app/controllers/admin/quiz_controller.rb | 2 +- app/controllers/admin_controller.rb | 3 + app/helpers/application_helper.rb | 8 ++ app/models/quiz.rb | 1 + app/views/admin/auth/login.html.erb | 23 ++++- app/views/admin/auth/logout.html.erb | 2 - app/views/admin/dashboard.html.erb | 19 +++- app/views/admin/question/index.html.erb | 2 - app/views/admin/quiz/_form.html.erb | 33 +++++-- app/views/admin/quiz/_table_list.html.erb | 19 ++++ app/views/admin/quiz/edit.html.erb | 9 +- app/views/admin/quiz/index.html.erb | 10 ++- app/views/admin/quiz/new.html.erb | 9 +- app/views/admin/quiz/view.html.erb | 9 +- app/views/admin/user/_form.html.erb | 34 ++++++-- app/views/admin/user/_table_list.html.erb | 17 ++++ app/views/admin/user/edit.html.erb | 9 +- app/views/admin/user/index.html.erb | 11 ++- app/views/admin/user/new.html.erb | 9 +- app/views/admin/user/view.html.erb | 12 ++- app/views/layouts/admin.html.erb | 46 ++++++++++ app/views/recruiter/create.html.erb | 2 - config/routes.rb | 87 ++++++++++--------- db/migrate/20160818225721_add_name_to_quiz.rb | 5 ++ db/schema.rb | 3 +- .../controllers/admin/quiz_controller_test.rb | 3 +- .../controllers/admin/user_controller_test.rb | 4 +- test/fixtures/quizzes.yml | 1 + 29 files changed, 316 insertions(+), 104 deletions(-) delete mode 100644 app/views/admin/auth/logout.html.erb create mode 100644 app/views/admin/quiz/_table_list.html.erb create mode 100644 app/views/admin/user/_table_list.html.erb create mode 100644 app/views/layouts/admin.html.erb delete mode 100644 app/views/recruiter/create.html.erb create mode 100644 db/migrate/20160818225721_add_name_to_quiz.rb diff --git a/Guardfile b/Guardfile index e686215..a200919 100644 --- a/Guardfile +++ b/Guardfile @@ -15,6 +15,20 @@ # # and, you'll have to watch "config/Guardfile" instead of "Guardfile" +guard 'livereload' do + watch(%r{app/assets/.+\.(scss|css|js|erb)}) + watch(%r{app/views/.+\.(erb|haml|slim)$}) + watch(%r{app/controllers/.+\.rb}) + watch(%r{app/helpers/.+\.rb}) + watch(%r{public/.+\.(css|js|html)}) + watch(%r{config/locales/.+\.yml}) + + # Rails Assets Pipeline + watch(%r{(app|vendor)(/assets/\w+/(.+\.(scss|css|js|erb|html|png|jpg))).*}) do |m| + "/assets/#{m[3]}" + end +end + guard :minitest, spring: true, all_after_pass: true, all_on_start: false do watch(%r{^test/test_helper\.rb$}) { 'test' } watch(%r{^test/(.*)\/?(.*)_test\.rb$}) @@ -32,20 +46,6 @@ guard :minitest, spring: true, all_after_pass: true, all_on_start: false do watch(%r{^app/views/(.*_mailer/)?([^/]+)\.erb$}) { ["test/mailers", "test/integration"] } end -guard 'livereload' do - watch(%r{app/assets/.+\.(scss|css|js|erb)}) - watch(%r{app/views/.+\.(erb|haml|slim)$}) - watch(%r{app/controllers/.+\.rb}) - watch(%r{app/helpers/.+\.rb}) - watch(%r{public/.+\.(css|js|html)}) - watch(%r{config/locales/.+\.yml}) - - # Rails Assets Pipeline - watch(%r{(app|vendor)(/assets/\w+/(.+\.(scss|css|js|erb|html|png|jpg))).*}) do |m| - "/assets/#{m[3]}" - end -end - guard :rubocop do watch(/.+\.rb$/) watch(/Rakefile/) diff --git a/app/controllers/admin/quiz_controller.rb b/app/controllers/admin/quiz_controller.rb index da05856..82c2de4 100644 --- a/app/controllers/admin/quiz_controller.rb +++ b/app/controllers/admin/quiz_controller.rb @@ -42,7 +42,7 @@ module Admin private def quiz_params - params.require(:quiz).permit(:dept, :unit) + params.require(:quiz).permit(:name, :dept, :unit) end end end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 55b4a93..37a79b4 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,7 +1,10 @@ class AdminController < ApplicationController + layout 'admin' before_action :authorize_admin def dashboard + @quizzes = Quiz.includes(:questions).all + @users = User.order(:role, :name) end def current_admin diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index feaaee8..cd6c340 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -9,4 +9,12 @@ module ApplicationHelper ["15+ Years", "15+"] ], disabled: "-", selected: (val.blank? ? '' : val)) end + + def admin_role_options val + options_for_select([ + %w(Reviewer reviewer), + %w(Recruiter recruiter), + %w(Admin admin) + ], disabled: "-", selected: (val.blank? ? '' : val)) + end end diff --git a/app/models/quiz.rb b/app/models/quiz.rb index 2f27521..bf967e4 100644 --- a/app/models/quiz.rb +++ b/app/models/quiz.rb @@ -2,6 +2,7 @@ class Quiz < ApplicationRecord has_many :questions, -> { order(:sort) } has_many :candidates + validates_presence_of :name validates_presence_of :dept validates_presence_of :unit end diff --git a/app/views/admin/auth/login.html.erb b/app/views/admin/auth/login.html.erb index 1aae790..b54def1 100644 --- a/app/views/admin/auth/login.html.erb +++ b/app/views/admin/auth/login.html.erb @@ -1,2 +1,21 @@ -

Admin::Auth#login

-

Find me in app/views/admin/auth/login.html.erb

+
+

Admin Login

+ + <% if flash[:error].present? %> +
<%= flash[:error] %>
+ <% end %> + + <%= form_for :auth, url: admin_login_path do |form| %> +
+ <%= form.label :email %> + <%= form.email_field :email %> +
+ +
+ <%= form.label :password %> + <%= form.password_field :password %> +
+ + <%= submit_tag "Log in" %> + <% end %> +
diff --git a/app/views/admin/auth/logout.html.erb b/app/views/admin/auth/logout.html.erb deleted file mode 100644 index 666b438..0000000 --- a/app/views/admin/auth/logout.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Admin::Auth#logout

-

Find me in app/views/admin/auth/logout.html.erb

diff --git a/app/views/admin/dashboard.html.erb b/app/views/admin/dashboard.html.erb index 4f3e250..b69057c 100644 --- a/app/views/admin/dashboard.html.erb +++ b/app/views/admin/dashboard.html.erb @@ -1 +1,18 @@ -huzzah! dashboard +<% + content_for :section_title, "Admin Dashboard" +%> + +
+
+

Quizzes

+ <%= render partial: 'admin/quiz/table_list', locals: { quizzes: @quizzes } %> + <%= link_to('New Quiz', admin_new_quiz_path, { class: 'btn' }) %> +
+ +
+

Users

+ <%= render partial: 'admin/user/table_list', locals: { users: @users } %> + <%= link_to('New User', admin_new_user_path, { class: 'btn' }) %> +
+ +
diff --git a/app/views/admin/question/index.html.erb b/app/views/admin/question/index.html.erb index dcbca37..e69de29 100644 --- a/app/views/admin/question/index.html.erb +++ b/app/views/admin/question/index.html.erb @@ -1,2 +0,0 @@ -

Admin::Questions#index

-

Find me in app/views/admin/questions/index.html.erb

diff --git a/app/views/admin/quiz/_form.html.erb b/app/views/admin/quiz/_form.html.erb index 2cc7e08..591a6f5 100644 --- a/app/views/admin/quiz/_form.html.erb +++ b/app/views/admin/quiz/_form.html.erb @@ -1,6 +1,29 @@ -<%= form_for quiz, url: action do |f| %> -

Unit: <%= f.text_field :unit %>

-

Dept: <%= f.text_field :dept %>

- - <%= f.submit %> +<% if flash[:error].present? %> +
+ <%= flash[:error] %> +

+ <% quiz.errors.messages.each do |k,v| %> + <%= "#{k.to_s} #{v.join(' and ')}" %>
+ <% end %> +

+
+<% end %> + +<%= form_for quiz, url: action do |form| %> +
+ <%= form.label :name, "Quiz Description" %> + <%= form.text_field :name %> +
+ +
+ <%= form.label :dept, 'Department' %> + <%= form.text_field :dept %> +
+ +
+ <%= form.label :unit, 'Unit' %> + <%= form.text_field :unit %> +
+ + <%= form.submit %> <% end %> diff --git a/app/views/admin/quiz/_table_list.html.erb b/app/views/admin/quiz/_table_list.html.erb new file mode 100644 index 0000000..98fbd79 --- /dev/null +++ b/app/views/admin/quiz/_table_list.html.erb @@ -0,0 +1,19 @@ + + + + + + + + + + <% quizzes.each do |quiz| %> + + + + + + + + <% end %> +
NameDeptUnitQuestions
<%= link_to quiz.name, admin_quiz_path(quiz.to_i) %><%= quiz.dept %><%= quiz.unit %><%= quiz.questions.count %><%= link_to 'edit', admin_edit_quiz_path(quiz.to_i), { class: 'btn tertiary-btn' } %>
diff --git a/app/views/admin/quiz/edit.html.erb b/app/views/admin/quiz/edit.html.erb index bdea931..f0435b9 100644 --- a/app/views/admin/quiz/edit.html.erb +++ b/app/views/admin/quiz/edit.html.erb @@ -1,4 +1,7 @@ -

Admin::Quizes#edit

-

Find me in app/views/admin/quizes/edit.html.erb

+<% + content_for :section_title, "Edit: #{@quiz.name}" +%> -<%= render partial: 'form', locals: { quiz: @quiz, action: admin_update_quiz_path } %> +
+ <%= render partial: 'form', locals: { quiz: @quiz, action: admin_update_quiz_path } %> +
diff --git a/app/views/admin/quiz/index.html.erb b/app/views/admin/quiz/index.html.erb index 458399a..4b1af23 100644 --- a/app/views/admin/quiz/index.html.erb +++ b/app/views/admin/quiz/index.html.erb @@ -1,2 +1,8 @@ -

Admin::Quizes#index

-

Find me in app/views/admin/quizes/index.html.erb

+<% + content_for :section_title, "Quizzes" +%> + +
+ <%= render partial: 'admin/quiz/table_list', locals: { quizzes: @quizzes } %> + <%= link_to('New Quiz', admin_new_quiz_path, { class: 'btn' }) %> +
diff --git a/app/views/admin/quiz/new.html.erb b/app/views/admin/quiz/new.html.erb index bac3d40..639e477 100644 --- a/app/views/admin/quiz/new.html.erb +++ b/app/views/admin/quiz/new.html.erb @@ -1,4 +1,7 @@ -

Admin::Quizes#new

-

Find me in app/views/admin/quizes/new.html.erb

+<% + content_for :section_title, "New Quiz" +%> -<%= render partial: 'form', locals: { quiz: @quiz, action: admin_create_quiz_path } %> +
+ <%= render partial: 'form', locals: { quiz: @quiz, action: admin_create_quiz_path } %> +
diff --git a/app/views/admin/quiz/view.html.erb b/app/views/admin/quiz/view.html.erb index 24ec89b..7047ca1 100644 --- a/app/views/admin/quiz/view.html.erb +++ b/app/views/admin/quiz/view.html.erb @@ -1,7 +1,10 @@ -

Admin::Quizes#view

-

Find me in app/views/admin/quizes/view.html.erb

+<% + content_for :section_title, "#{@quiz.name}" +%> -
+
+

<%= @quiz.name %>

<%= @quiz.dept %>

<%= @quiz.unit %>

+ <%= link_to('Edit', admin_edit_quiz_path(@quiz.to_i), { class: 'btn' }) %>
diff --git a/app/views/admin/user/_form.html.erb b/app/views/admin/user/_form.html.erb index 164f74e..4edf982 100644 --- a/app/views/admin/user/_form.html.erb +++ b/app/views/admin/user/_form.html.erb @@ -1,7 +1,29 @@ -<%= form_for user, url: action do |f| %> -

Name: <%= f.text_field :name %>

-

eMail: <%= f.email_field :email %>

-

Role: <%= f.text_field :role %>

- - <%= f.submit %> +<% if flash[:error].present? %> +
+ <%= flash[:error] %> +

+ <% user.errors.messages.each do |k,v| %> + <%= "#{k.to_s} #{v.join(' and ')}" %>
+ <% end %> +

+
+<% end %> + +<%= form_for user, url: action do |form| %> +
+ <%= form.label :name, "Full Name" %> + <%= form.text_field :name %> +
+ +
+ <%= form.label :email, "eMail" %> + <%= form.email_field :email %> +
+ +
+ <%= form.label :role, "Role" %> + <%= form.select :role, admin_role_options(user.role), include_blank: false %> +
+ + <%= form.submit %> <% end %> diff --git a/app/views/admin/user/_table_list.html.erb b/app/views/admin/user/_table_list.html.erb new file mode 100644 index 0000000..bcce061 --- /dev/null +++ b/app/views/admin/user/_table_list.html.erb @@ -0,0 +1,17 @@ + + + + + + + + + <% users.each do |user| %> + + + + + + + <% end %> +
UserEmailRole
<%= link_to user.name, admin_user_path(user.to_i) %><%= mail_to(user.email) %><%= user.role %><%= link_to 'edit', admin_edit_user_path(user.to_i), { class: 'btn tertiary-btn' } %>
diff --git a/app/views/admin/user/edit.html.erb b/app/views/admin/user/edit.html.erb index b438098..7d30c1a 100644 --- a/app/views/admin/user/edit.html.erb +++ b/app/views/admin/user/edit.html.erb @@ -1,4 +1,7 @@ -

Admin::Users#edit

-

Find me in app/views/admin/users/edit.html.erb

+<% + content_for :section_title, "Edit: #{@user.name}" +%> -<%= render partial: 'form', locals: {user: @user, action: admin_update_user_path } %> +
+ <%= render partial: 'form', locals: {user: @user, action: admin_update_user_path } %> +
diff --git a/app/views/admin/user/index.html.erb b/app/views/admin/user/index.html.erb index 30c6fab..0d25eb9 100644 --- a/app/views/admin/user/index.html.erb +++ b/app/views/admin/user/index.html.erb @@ -1,2 +1,9 @@ -

Admin::Users#index

-

Find me in app/views/admin/users/index.html.erb

+<% + content_for :section_title, "Users" +%> + +
+

Users

+ <%= render partial: 'admin/user/table_list', locals: { users: @users } %> + <%= link_to('New User', admin_new_user_path, { class: 'btn' }) %> +
diff --git a/app/views/admin/user/new.html.erb b/app/views/admin/user/new.html.erb index f076758..16906ea 100644 --- a/app/views/admin/user/new.html.erb +++ b/app/views/admin/user/new.html.erb @@ -1,4 +1,7 @@ -

Admin::Users#new

-

Find me in app/views/admin/users/new.html.erb

+<% + content_for :section_title, "New User" +%> -<%= render partial: 'form', locals: {user: @user, action: admin_create_user_path } %> +
+ <%= render partial: 'form', locals: {user: @user, action: admin_create_user_path } %> +
diff --git a/app/views/admin/user/view.html.erb b/app/views/admin/user/view.html.erb index ca68938..3890172 100644 --- a/app/views/admin/user/view.html.erb +++ b/app/views/admin/user/view.html.erb @@ -1,6 +1,10 @@ -

Admin::Users#view

-

Find me in app/views/admin/users/view.html.erb

+<% + content_for :section_title, "#{@user.name}" +%> -
- <%= @user.name %> +
+

<%= @user.name %>

+

<%= mail_to(@user.email) %>

+

<%= @user.role %>

+ <%= link_to('Edit', admin_edit_user_path(@user.to_i), { class: 'btn' }) %>
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb new file mode 100644 index 0000000..05fa14f --- /dev/null +++ b/app/views/layouts/admin.html.erb @@ -0,0 +1,46 @@ + + + + + + <%= csrf_meta_tags %> + + <%= yield(:title) %> + + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + + + + + + + +
+ +
+
+ <% if content_for?(:section_title) %> +
<%= yield(:section_title) %>
+ <% else %> +
Skills Assessment Admin
+ <% end %> +
+
+ + <%= yield %> + +
+ +
+ + +
+ + + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + diff --git a/app/views/recruiter/create.html.erb b/app/views/recruiter/create.html.erb deleted file mode 100644 index abf096a..0000000 --- a/app/views/recruiter/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Recruiter#create

-

Find me in app/views/recruiter/create.html.erb

diff --git a/config/routes.rb b/config/routes.rb index ca102d9..7f0cb37 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,58 +1,61 @@ Rails.application.routes.draw do post "/admin/login", to: "admin/auth#auth", as: :admin_auth - get "/admin/login", to: "admin/auth#login", as: :admin_login - get "/admin/logout", to: "admin/auth#logout", as: :admin_logout + get "/admin/login", to: "admin/auth#login", as: :admin_login + get "/admin/logout", to: "admin/auth#logout", as: :admin_logout - get "/admin", to: "admin#dashboard", as: :admin + get "/admin", to: "admin#dashboard", as: :admin - get "/admin/quizzes", to: "admin/quiz#index", as: :admin_quizzes - get "/admin/quiz/new", to: "admin/quiz#new", as: :admin_new_quiz - post "/admin/quiz/create", to: "admin/quiz#create", as: :admin_create_quiz - get "/admin/quiz/:quiz_id", to: "admin/quiz#view", as: :admin_quiz - get "/admin/quiz/:quiz_id/edit", to: "admin/quiz#edit", as: :admin_edit_quiz - post "/admin/quiz/:quiz_id/update", to: "admin/quiz#update", as: :admin_update_quiz + get "/admin/quizzes", to: "admin/quiz#index", as: :admin_quizzes + get "/admin/quiz/new", to: "admin/quiz#new", as: :admin_new_quiz + post "/admin/quiz/new", to: "admin/quiz#create", as: :admin_create_quiz + get "/admin/quiz/:quiz_id", to: "admin/quiz#view", as: :admin_quiz + get "/admin/quiz/:quiz_id/edit", to: "admin/quiz#edit", as: :admin_edit_quiz + post "/admin/quiz/:quiz_id/edit", to: "admin/quiz#update", as: :admin_update_quiz + patch "/admin/quiz/:quiz_id/edit", to: "admin/quiz#update" - get "/admin/users", to: "admin/user#index", as: :admin_users - get "/admin/user/new", to: "admin/user#new", as: :admin_new_user - post "/admin/user/create", to: "admin/user#create", as: :admin_create_user - get "/admin/user/:user_id", to: "admin/user#view", as: :admin_user - get "/admin/user/:user_id/edit", to: "admin/user#edit", as: :admin_edit_user - post "/admin/user/:user_id/update", to: "admin/user#update", as: :admin_update_user + get "/admin/users", to: "admin/user#index", as: :admin_users + get "/admin/user/new", to: "admin/user#new", as: :admin_new_user + post "/admin/user/new", to: "admin/user#create", as: :admin_create_user + get "/admin/user/:user_id", to: "admin/user#view", as: :admin_user + get "/admin/user/:user_id/edit", to: "admin/user#edit", as: :admin_edit_user + post "/admin/user/:user_id/edit", to: "admin/user#update", as: :admin_update_user + patch "/admin/user/:user_id/edit", to: "admin/user#update" - get "/admin/questions", to: "admin/question#index", as: :admin_questions - get "/admin/question/new", to: "admin/question#new", as: :admin_new_question - post "/admin/question/create", to: "admin/question#create", as: :admin_create_question - get "/admin/question/:question_id", to: "admin/question#view", as: :admin_question - get "/admin/question/:question_id/edit", to: "admin/question#edit", as: :admin_edit_question - post "/admin/question/:question_id/update", to: "admin/question#update", as: :admin_update_question + get "/admin/questions", to: "admin/question#index", as: :admin_questions + get "/admin/question/new", to: "admin/question#new", as: :admin_new_question + post "/admin/question/new", to: "admin/question#create", as: :admin_create_question + get "/admin/question/:question_id", to: "admin/question#view", as: :admin_question + get "/admin/question/:question_id/edit", to: "admin/question#edit", as: :admin_edit_question + post "/admin/question/:question_id/edit", to: "admin/question#update", as: :admin_update_question + patch "/admin/question/:question_id/edit", to: "admin/question#update" ######################################################################################### - post "/validate", to: "candidate#validate", as: :validate_candidate - get "/login(/:test_id)", to: "candidate#login", as: :login - get "/welcome", to: "candidate#welcome", as: :welcome - get "/saved", to: "candidate#saved", as: :saved - get "/thankyou", to: "candidate#thankyou", as: :thankyou + post "/validate", to: "candidate#validate", as: :validate_candidate + get "/login(/:test_id)", to: "candidate#login", as: :login + get "/welcome", to: "candidate#welcome", as: :welcome + get "/saved", to: "candidate#saved", as: :saved + get "/thankyou", to: "candidate#thankyou", as: :thankyou - get "/oops", to: "candidate#oops", as: :oops + get "/oops", to: "candidate#oops", as: :oops - post "/question(/:answer_id)", to: "quiz#update_answer", as: :post_answer - get "/question(/:question_id)", to: "quiz#question", as: :question - post "/summary", to: "quiz#submit_summary", as: :post_summary - get "/summary", to: "quiz#summary", as: :summary + post "/question(/:answer_id)", to: "quiz#update_answer", as: :post_answer + get "/question(/:question_id)", to: "quiz#question", as: :question + post "/summary", to: "quiz#submit_summary", as: :post_summary + get "/summary", to: "quiz#summary", as: :summary - get "/review/logout", to: "review#logout", as: :review_logout - post "/review/login", to: "review#auth", as: :review_auth - get "/review/login", to: "review#login", as: :review_login - get "/review", to: "review#index", as: :review - get "/review/:test_hash", to: "review#view", as: :review_test + get "/review/logout", to: "review#logout", as: :review_logout + post "/review/login", to: "review#auth", as: :review_auth + get "/review/login", to: "review#login", as: :review_login + get "/review", to: "review#index", as: :review + get "/review/:test_hash", to: "review#view", as: :review_test - get "/recruiter", to: "recruiter#index", as: :recruiter - get "/recruiter/new-candidate", to: "recruiter#new", as: :new_candidate - post "/recruiter/new-candidate", to: "recruiter#create", as: :create_candidate - get "/recruiter/logout", to: "recruiter#logout", as: :recruiter_logout - get "/recruiter/login", to: "recruiter#login", as: :recruiter_login - post "/recruiter/login", to: "recruiter#auth", as: :recruiter_auth + get "/recruiter", to: "recruiter#index", as: :recruiter + get "/recruiter/new-candidate", to: "recruiter#new", as: :new_candidate + post "/recruiter/new-candidate", to: "recruiter#create", as: :create_candidate + get "/recruiter/logout", to: "recruiter#logout", as: :recruiter_logout + get "/recruiter/login", to: "recruiter#login", as: :recruiter_login + post "/recruiter/login", to: "recruiter#auth", as: :recruiter_auth root to: "candidate#login" diff --git a/db/migrate/20160818225721_add_name_to_quiz.rb b/db/migrate/20160818225721_add_name_to_quiz.rb new file mode 100644 index 0000000..a8ecd97 --- /dev/null +++ b/db/migrate/20160818225721_add_name_to_quiz.rb @@ -0,0 +1,5 @@ +class AddNameToQuiz < ActiveRecord::Migration[5.0] + def change + add_column :quizzes, :name, :string, after: :id + end +end diff --git a/db/schema.rb b/db/schema.rb index 61aa979..2085033 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160803003932) do +ActiveRecord::Schema.define(version: 20160818225721) do create_table "answers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.integer "candidate_id" @@ -62,6 +62,7 @@ ActiveRecord::Schema.define(version: 20160803003932) do t.string "dept" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "name" end create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| diff --git a/test/controllers/admin/quiz_controller_test.rb b/test/controllers/admin/quiz_controller_test.rb index fd16e59..b638661 100644 --- a/test/controllers/admin/quiz_controller_test.rb +++ b/test/controllers/admin/quiz_controller_test.rb @@ -29,7 +29,8 @@ module Admin test "should post create" do assert_difference("Quiz.count", 1) do - post admin_create_quiz_url, params: { quiz: { unit: 'PDW', dept: 'MBL' } } + post admin_create_quiz_url, params: { quiz: + { name: 'PDW Mobile team screening', unit: 'PDW', dept: 'MBL' } } end assert_redirected_to admin_quizzes_url end diff --git a/test/controllers/admin/user_controller_test.rb b/test/controllers/admin/user_controller_test.rb index 972ebf4..8416cc8 100644 --- a/test/controllers/admin/user_controller_test.rb +++ b/test/controllers/admin/user_controller_test.rb @@ -39,7 +39,7 @@ module Admin user = users(:recruiter) get admin_user_url user.to_i assert_response :success - assert_select 'main', user.name + assert_select 'p', user.name end test "should get edit" do @@ -55,7 +55,7 @@ module Admin assert_redirected_to admin_user_path(user.to_i) get admin_user_url user.to_i - assert_select 'main', 'new name' + assert_select 'p', 'new name' end test "should fail to update user" do diff --git a/test/fixtures/quizzes.yml b/test/fixtures/quizzes.yml index 87dc32d..daf1e5d 100644 --- a/test/fixtures/quizzes.yml +++ b/test/fixtures/quizzes.yml @@ -1,5 +1,6 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html fed: + name: PDR Standard FED Screening unit: PDR dept: FED