diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -60,4 +60,8 @@ end end + def logout + redirect_to root_path + end + end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -21,6 +21,7 @@ redirect_to :action => 'login' end + #reset login, clear session def login saved_notice = flash[:notice] reset_session @@ -40,6 +41,11 @@ render :action => 'login', :layout => 'empty' end + def logout + reset_session + redirect_to root_path + end + def list prepare_list_information end diff --git a/app/views/main/_submission_short.html.haml b/app/views/main/_submission_short.html.haml --- a/app/views/main/_submission_short.html.haml +++ b/app/views/main/_submission_short.html.haml @@ -21,8 +21,8 @@ - if GraderConfiguration.show_grading_result = link_to '[detailed result]', :action => 'result', :id => submission.id /= link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'} - = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission.id), {popup: true,remote: true,class: 'btn btn-xs btn-info'} - = link_to "#{t 'main.src_link'}",{:action => 'source', :id => submission.id}, class: 'btn btn-xs btn-info' + = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission), {popup: true,remote: true,class: 'btn btn-xs btn-info'} + = link_to "#{t 'main.src_link'}",download_submission_path(submission), class: 'btn btn-xs btn-info' = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info' - if GraderConfiguration.show_testcase = link_to "testcases", show_problem_testcases_path(problem_id), class: 'btn btn-xs btn-info' diff --git a/app/views/user_admin/admin.html.haml b/app/views/user_admin/admin.html.haml --- a/app/views/user_admin/admin.html.haml +++ b/app/views/user_admin/admin.html.haml @@ -17,9 +17,9 @@ %hr = form_tag :action => 'grant_admin' do - Grant admin permission to: - = text_field_tag 'login' - = submit_tag 'Grant' + = label_tag :login, 'Grant admin permission to:' + = text_field_tag 'login',nil, class: 'input-field' + = submit_tag 'Grant', class: 'btn btn-primary' %hr/ = link_to '[go back to index]', :action => 'index' diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -7,11 +7,8 @@ #logins match 'login/login', to: 'login#login', via: [:get,:post] - resources :contests - resources :sites - resources :test resources :messages do @@ -93,7 +90,7 @@ #user admin - resources :user_admin do + resources :user_admin do collection do match 'bulk_manage', via: [:get, :post] get 'bulk_mail' @@ -103,6 +100,7 @@ get 'admin' get 'active' get 'mass_mailing' + get 'revoke_admin' post 'grant_admin' match 'create_from_list', via: [:get, :post] match 'random_all_passwords', via: [:get, :post] @@ -144,11 +142,13 @@ #post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score' resource :main, only: [], controller: 'main' do + get 'login' + get 'logout' get 'list' get 'submission(/:id)', action: 'submission', as: 'main_submission' - post 'submit' get 'announcements' get 'help' + post 'submit' end #main #get "main/list" diff --git a/db/migrate/20180612102327_change_submission_source_size.rb b/db/migrate/20180612102327_change_submission_source_size.rb --- a/db/migrate/20180612102327_change_submission_source_size.rb +++ b/db/migrate/20180612102327_change_submission_source_size.rb @@ -1,4 +1,4 @@ -class ChangeSubmissionSourceSize < ActiveRecord::Migration +class ChangeSubmissionSourceSize < ActiveRecord::Migration[4.2] def change change_column :submissions, :source, :text, :limit => 1.megabyte end diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -10,296 +10,295 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180612102327) do +ActiveRecord::Schema.define(version: 2018_06_12_102327) do - create_table "announcements", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "author" - t.text "body", limit: 65535 - t.boolean "published" + create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "author" + t.text "body" + t.boolean "published" t.datetime "created_at" t.datetime "updated_at" - t.boolean "frontpage", default: false - t.boolean "contest_only", default: false - t.string "title" - t.string "notes" + t.boolean "frontpage", default: false + t.boolean "contest_only", default: false + t.string "title" + t.string "notes" end - create_table "contests", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "title" - t.boolean "enabled" + create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "title" + t.boolean "enabled" t.datetime "created_at" t.datetime "updated_at" - t.string "name" + t.string "name" end - create_table "contests_problems", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.integer "contest_id" t.integer "problem_id" end - create_table "contests_users", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.integer "contest_id" t.integer "user_id" end - create_table "countries", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "name" + create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name" t.datetime "created_at" t.datetime "updated_at" end - create_table "descriptions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.text "body", limit: 65535 - t.boolean "markdowned" + create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.text "body" + t.boolean "markdowned" t.datetime "created_at" t.datetime "updated_at" end - create_table "grader_configurations", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "key" - t.string "value_type" - t.string "value" + create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "key" + t.string "value_type" + t.string "value" t.datetime "created_at" t.datetime "updated_at" - t.text "description", limit: 65535 + t.text "description" end - create_table "grader_processes", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "host" - t.integer "pid" - t.string "mode" - t.boolean "active" + create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "host" + t.integer "pid" + t.string "mode" + t.boolean "active" t.datetime "created_at" t.datetime "updated_at" - t.integer "task_id" - t.string "task_type" - t.boolean "terminated" - t.index ["host", "pid"], name: "index_grader_processes_on_host_and_pid", using: :btree + t.integer "task_id" + t.string "task_type" + t.boolean "terminated" + t.index ["host", "pid"], name: "index_grader_processes_on_ip_and_pid" end - create_table "groups", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| t.string "name" t.string "description" end - create_table "groups_problems", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| t.integer "problem_id", null: false - t.integer "group_id", null: false - t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id", using: :btree + t.integer "group_id", null: false + t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id" end - create_table "groups_users", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "groups_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| t.integer "group_id", null: false - t.integer "user_id", null: false - t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id", using: :btree + t.integer "user_id", null: false + t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id" end - create_table "heart_beats", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "user_id" - t.string "ip_address" - t.datetime "created_at" - t.datetime "updated_at" - t.string "status" - t.index ["updated_at"], name: "index_heart_beats_on_updated_at", using: :btree + create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + t.integer "user_id" + t.string "ip_address" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "status" + t.index ["updated_at"], name: "index_heart_beats_on_updated_at" end - create_table "languages", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "name", limit: 10 + create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name", limit: 10 t.string "pretty_name" - t.string "ext", limit: 10 + t.string "ext", limit: 10 t.string "common_ext" end - create_table "logins", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "user_id" - t.string "ip_address" + create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + t.integer "user_id" + t.string "ip_address" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "sender_id" + t.integer "receiver_id" + t.integer "replying_message_id" + t.text "body" + t.boolean "replied" t.datetime "created_at" t.datetime "updated_at" end - create_table "messages", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "sender_id" - t.integer "receiver_id" - t.integer "replying_message_id" - t.text "body", limit: 65535 - t.boolean "replied" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "problems", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "name", limit: 30 - t.string "full_name" + create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name", limit: 30 + t.string "full_name" t.integer "full_score" - t.date "date_added" + t.date "date_added" t.boolean "available" - t.string "url" + t.string "url" t.integer "description_id" t.boolean "test_allowed" t.boolean "output_only" - t.string "description_filename" + t.string "description_filename" t.boolean "view_testcase" end - create_table "problems_tags", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "problems_tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| t.integer "problem_id" t.integer "tag_id" - t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true, using: :btree - t.index ["problem_id"], name: "index_problems_tags_on_problem_id", using: :btree - t.index ["tag_id"], name: "index_problems_tags_on_tag_id", using: :btree + t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true + t.index ["problem_id"], name: "index_problems_tags_on_problem_id" + t.index ["tag_id"], name: "index_problems_tags_on_tag_id" end - create_table "rights", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.string "name" t.string "controller" t.string "action" end - create_table "rights_roles", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.integer "right_id" t.integer "role_id" - t.index ["role_id"], name: "index_rights_roles_on_role_id", using: :btree + t.index ["role_id"], name: "index_rights_roles_on_role_id" end - create_table "roles", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.string "name" end - create_table "roles_users", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| + create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.integer "role_id" t.integer "user_id" - t.index ["user_id"], name: "index_roles_users_on_user_id", using: :btree + t.index ["user_id"], name: "index_roles_users_on_user_id" end - create_table "sessions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "session_id" - t.text "data", limit: 65535 + create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "session_id" + t.text "data" t.datetime "updated_at" - t.index ["session_id"], name: "index_sessions_on_session_id", using: :btree - t.index ["updated_at"], name: "index_sessions_on_updated_at", using: :btree + t.index ["session_id"], name: "index_sessions_on_session_id" + t.index ["updated_at"], name: "index_sessions_on_updated_at" end - create_table "sites", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "name" - t.boolean "started" + create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name" + t.boolean "started" t.datetime "start_time" t.datetime "created_at" t.datetime "updated_at" - t.integer "country_id" - t.string "password" + t.integer "country_id" + t.string "password" + end + + create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + t.integer "user_id" + t.integer "submission_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "submission_view_logs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "user_id" - t.integer "submission_id" + create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "user_id" + t.integer "problem_id" + t.integer "language_id" + t.text "source", limit: 16777215 + t.binary "binary" + t.datetime "submitted_at" + t.datetime "compiled_at" + t.text "compiler_message" + t.datetime "graded_at" + t.integer "points" + t.text "grader_comment" + t.integer "number" + t.string "source_filename" + t.float "max_runtime" + t.integer "peak_memory" + t.integer "effective_code_length" + t.string "ip_address" + t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true + t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id" + end + + create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| + t.string "name", null: false + t.text "description" + t.boolean "public" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "submission_id" + t.datetime "created_at" + t.integer "status" + t.datetime "updated_at" + t.index ["submission_id"], name: "index_tasks_on_submission_id" + end + + create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "problem_id" + t.text "input", limit: 16777215 + t.text "solution", limit: 16777215 t.datetime "created_at" t.datetime "updated_at" end - create_table "submissions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "user_id" - t.integer "problem_id" - t.integer "language_id" - t.text "source", limit: 16777215 - t.binary "binary", limit: 65535 + create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "user_id" + t.integer "problem_id" + t.integer "submission_id" + t.string "input_file_name" + t.string "output_file_name" + t.string "running_stat" + t.integer "status" + t.datetime "updated_at" t.datetime "submitted_at" t.datetime "compiled_at" - t.text "compiler_message", limit: 65535 + t.text "compiler_message" t.datetime "graded_at" - t.integer "points" - t.text "grader_comment", limit: 65535 - t.integer "number" - t.string "source_filename" - t.float "max_runtime", limit: 24 - t.integer "peak_memory" - t.integer "effective_code_length" - t.string "ip_address" - t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true, using: :btree - t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id", using: :btree + t.string "grader_comment" + t.datetime "created_at" + t.float "running_time" + t.string "exit_status" + t.integer "memory_usage" + t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id" end - create_table "tags", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "name", null: false - t.text "description", limit: 65535 - t.boolean "public" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "testcases", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| + t.integer "problem_id" + t.integer "num" + t.integer "group" + t.integer "score" + t.text "input", limit: 4294967295 + t.text "sol", limit: 4294967295 + t.datetime "created_at" + t.datetime "updated_at" + t.index ["problem_id"], name: "index_testcases_on_problem_id" end - create_table "tasks", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "submission_id" - t.datetime "created_at" - t.integer "status" - t.datetime "updated_at" - t.index ["submission_id"], name: "index_tasks_on_submission_id", using: :btree - end - - create_table "test_pairs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "problem_id" - t.text "input", limit: 16777215 - t.text "solution", limit: 16777215 + create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "user_id" + t.datetime "started_at" t.datetime "created_at" t.datetime "updated_at" end - create_table "test_requests", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "user_id" - t.integer "problem_id" - t.integer "submission_id" - t.string "input_file_name" - t.string "output_file_name" - t.string "running_stat" - t.integer "status" - t.datetime "updated_at" - t.datetime "submitted_at" - t.datetime "compiled_at" - t.text "compiler_message", limit: 65535 - t.datetime "graded_at" - t.string "grader_comment" - t.datetime "created_at" - t.float "running_time", limit: 24 - t.string "exit_status" - t.integer "memory_usage" - t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id", using: :btree - end - - create_table "testcases", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "problem_id" - t.integer "num" - t.integer "group" - t.integer "score" - t.text "input", limit: 4294967295 - t.text "sol", limit: 4294967295 + create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "login", limit: 50 + t.string "full_name" + t.string "hashed_password" + t.string "salt", limit: 5 + t.string "alias" + t.string "email" + t.integer "site_id" + t.integer "country_id" + t.boolean "activated", default: false t.datetime "created_at" t.datetime "updated_at" - t.index ["problem_id"], name: "index_testcases_on_problem_id", using: :btree - end - - create_table "user_contest_stats", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.integer "user_id" - t.datetime "started_at" - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "forced_logout" - end - - create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "login", limit: 50 - t.string "full_name" - t.string "hashed_password" - t.string "salt", limit: 5 - t.string "alias" - t.string "email" - t.integer "site_id" - t.integer "country_id" - t.boolean "activated", default: false - t.datetime "created_at" - t.datetime "updated_at" - t.string "section" - t.boolean "enabled", default: true - t.string "remark" - t.string "last_ip" - t.index ["login"], name: "index_users_on_login", unique: true, using: :btree + t.string "section" + t.boolean "enabled", default: true + t.string "remark" + t.string "last_ip" + t.index ["login"], name: "index_users_on_login", unique: true end add_foreign_key "problems_tags", "problems" diff --git a/test/system/users_test.rb b/test/system/users_test.rb --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -41,6 +41,58 @@ assert_text 'section 2' end + test "add multiple users" do + login 'admin', 'admin' + within 'header' do + click_on 'Manage' + click_on 'Users', match: :first + end + + click_on 'New list of users', match: :first + find(:css, 'textarea').fill_in with:"abc1,Boaty McBoatface,abcdef,alias1,remark1,\nabc2,Boaty2 McSecond,acbdef123,aias2,remark2" + click_on 'create users' + + assert_text('remark1') + assert_text('remark2') + end + + test "grant admin right" do + login 'admin', 'admin' + within 'header' do + click_on 'Manage' + click_on 'Users', match: :first + end + + click_on "View administrator" + fill_in 'login', with: 'john' + click_on "Grant" + + visit logout_main_path + login 'john','hello' + within 'header' do + click_on 'Manage' + click_on 'Problem', match: :first + end + assert_text "Turn off all problems" + end + + test "try using admin from normal user" do + login 'admin','admin' + visit bulk_manage_user_admin_index_path + assert_current_path bulk_manage_user_admin_index_path + visit logout_main_path + + login 'jack','morning' + visit bulk_manage_user_admin_index_path + assert_current_path root_path + assert_text 'You are not authorized' + + login 'james','morning' + visit new_list_user_admin_index_path + assert_current_path root_path + assert_text 'You are not authorized' + end + def login(username,password) visit root_path fill_in "Login", with: username