From 4eee70a84539e736ae87d852509b5fbef6a491b0 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 16 Jul 2014 17:46:17 +0800 Subject: [PATCH] course new/created test --- app/models/user.rb | 2 +- test/fixtures/enabled_modules.yml | 51 +++++++ test/fixtures/member_roles.yml | 5 + test/fixtures/members.yml | 7 + test/fixtures/roles.yml | 154 +++++++++++++++++++++ test/functional/courses_controller_test.rb | 29 +++- 6 files changed, 243 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9665a4fb0..195346e7c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -996,4 +996,4 @@ class AnonymousUser < User def destroy false end -end \ No newline at end of file +end diff --git a/test/fixtures/enabled_modules.yml b/test/fixtures/enabled_modules.yml index edb2e6972..a0a157142 100644 --- a/test/fixtures/enabled_modules.yml +++ b/test/fixtures/enabled_modules.yml @@ -103,3 +103,54 @@ enabled_modules_026: name: repository project_id: 2 id: 26 +#trustie +enabled_modules_trustie_001: + id: 415 + project_id: -1 + name: issue_tracking + course_id: 8 +enabled_modules_trustie_002: + id: 416 + project_id: -1 + name: time_tracking + course_id: 8 +enabled_modules_trustie_003: + id: 417 + project_id: -1 + name: news + course_id: 8 +enabled_modules_trustie_004: + id: 418 + project_id: -1 + name: documents + course_id: 8 +enabled_modules_trustie_005: + id: 419 + project_id: -1 + name: files + course_id: 8 +enabled_modules_trustie_006: + id: 420 + project_id: -1 + name: wiki + course_id: 8 +enabled_modules_trustie_007: + id: 421 + project_id: -1 + name: repository + course_id: 8 +enabled_modules_trustie_008: + id: 422 + project_id: -1 + name: boards + course_id: 8 +enabled_modules_trustie_009: + id: 423 + project_id: -1 + name: calendar + course_id: 8 +enabled_modules_trustie_010: + id: 424 + project_id: -1 + name: gantt + course_id: 8 diff --git a/test/fixtures/member_roles.yml b/test/fixtures/member_roles.yml index 999985395..79a8a8530 100644 --- a/test/fixtures/member_roles.yml +++ b/test/fixtures/member_roles.yml @@ -47,3 +47,8 @@ member_roles_011: role_id: 2 member_id: 10 inherited_from: 10 +member_roles_179: + id: 179 + member_id: 126 + role_id: 3 + inherited_from: diff --git a/test/fixtures/members.yml b/test/fixtures/members.yml index 10d52f300..7f918f683 100644 --- a/test/fixtures/members.yml +++ b/test/fixtures/members.yml @@ -60,3 +60,10 @@ members_010: project_id: 2 user_id: 8 mail_notification: false +members_course_001: + id: 126 + user_id: 5 + project_id: -1 + created_on: 2013-09-30 15:36:00.000000000 Z + mail_notification: false + course_id: 8 diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml index 6f4b6724d..00fbdfb56 100644 --- a/test/fixtures/roles.yml +++ b/test/fixtures/roles.yml @@ -199,4 +199,158 @@ roles_005: - :view_changesets position: 5 +roles_trustie_001: + id: 7 + name: 助教 + position: 6 + assignable: true + builtin: 0 + permissions: + - :add_project + - :edit_project + - :manage_members + - :view_journals_for_messages + - :add_course + - :edit_course + - :close_course + - :select_course_modules + - :view_course_journals_for_messages + - :manage_files + - :view_course_files + - :comment_news + - :manage_boards + - :add_messages + - :delete_own_messages + - :view_calendar + - :view_documents + - :view_files + - :view_gantt + - :view_issues + - :add_issues + - :add_issue_notes + - :save_queries + - :browse_repository + - :view_changesets + - :view_time_entries + - :view_wiki_pages + - :export_wiki_pages + - :view_wiki_edits + - :edit_wiki_pages + - :delete_wiki_pages_attachments + - :as_teacher + issues_visibility: default +roles_trustie_002: + id: 9 + name: 老师 + position: 7 + assignable: true + builtin: 0 + permissions: + - :add_project + - :edit_project + - :close_project + - :select_project_modules + - :manage_members + - :manage_versions + - :add_subprojects + - :view_journals_for_messages + - :add_course + - :edit_course + - :close_course + - :select_course_modules + - :view_course_journals_for_messages + - :manage_files + - :view_course_files + - :manage_news + - :comment_news + - :manage_boards + - :add_messages + - :edit_messages + - :edit_own_messages + - :delete_messages + - :delete_own_messages + - :view_calendar + - :add_documents + - :edit_documents + - :delete_documents + - :view_documents + - :view_files + - :view_gantt + - :manage_categories + - :view_issues + - :add_issues + - :edit_issues + - :manage_issue_relations + - :manage_subtasks + - :set_issues_private + - :set_own_issues_private + - :add_issue_notes + - :edit_issue_notes + - :edit_own_issue_notes + - :view_private_notes + - :set_notes_private + - :move_issues + - :delete_issues + - :manage_public_queries + - :save_queries + - :view_issue_watchers + - :add_issue_watchers + - :delete_issue_watchers + - :manage_repository + - :browse_repository + - :view_changesets + - :commit_access + - :manage_related_issues + - :log_time + - :view_time_entries + - :edit_time_entries + - :edit_own_time_entries + - :manage_project_activities + - :manage_wiki + - :rename_wiki_pages + - :delete_wiki_pages + - :view_wiki_pages + - :export_wiki_pages + - :view_wiki_edits + - :edit_wiki_pages + - :delete_wiki_pages_attachments + - :protect_wiki_pages + - :as_teacher + issues_visibility: default +roles_trustie_003: + id: 10 + name: 学生 + position: 8 + assignable: true + builtin: 0 + permissions: + - :add_project + - :view_journals_for_messages + - :add_course + - :edit_course + - :close_course + - :select_course_modules + - :view_course_journals_for_messages + - :view_course_files + - :comment_news + - :manage_boards + - :add_messages + - :edit_own_messages + - :delete_own_messages + - :view_calendar + - :view_documents + - :view_files + - :view_gantt + - :view_issues + - :add_issues + - :add_issue_notes + - :save_queries + - :browse_repository + - :view_changesets + - :view_time_entries + - :view_wiki_pages + - :view_wiki_edits + - :paret_in_homework + - :as_student + issues_visibility: default diff --git a/test/functional/courses_controller_test.rb b/test/functional/courses_controller_test.rb index 865a4524d..ebd0325b3 100644 --- a/test/functional/courses_controller_test.rb +++ b/test/functional/courses_controller_test.rb @@ -19,14 +19,35 @@ class CoursesControllerTest < ActionController::TestCase assert courses.all?(&:is_public?) end - test "test_create_courses_anyone_temporary" do + # 人员添加课程的权限是不属于任何角色 + def test_new_course_anyone_temporary @request.session[:user_id] = 5 - Role.find(2).add_permisstion! :add_course - + Role.find_by_name("Non member").add_permission! :add_course #Non member get :new - assert_redirected_to new_course_path assert_response :success + assert_template :new + end + + def test_create_course_anyone_temporary + @request.session[:user_id] = 5 + Role.find_by_name("Non member").add_permission! :add_course #Non member + + post :create, + :class_period => '32', + :time => '2014', + :term => 'spring', + :course => { + :name => 'course one', + :password => '1234', + :description => 'description', + :is_public => '1234', + :course_type => '1' + } + assert_response :found + course = Course.find_by_name('course one') + assert_redirected_to "courses/#{course.id}/settings" + #assert_redirected_to "courses/#{course.id}/settings" end # test "#index by non-admin user with view_time_entries permission should show overall spent time link" do