From 233f041cc56e2146067998c1a64f502e5e2e7729 Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 29 Jul 2014 12:05:24 +0800 Subject: [PATCH] . --- test/fixtures/course_infos.yml | 18 ++- test/fixtures/course_statuses.yml | 11 +- test/fixtures/courses.yml | 160 +++------------------ test/fixtures/member_roles.yml | 5 - test/fixtures/members.yml | 7 - test/fixtures/schools.yml | 16 ++- test/fixtures/user_extensions.yml | 103 ++++++------- test/fixtures/users.yml | 29 ++-- test/functional/courses_controller_test.rb | 19 ++- 9 files changed, 118 insertions(+), 250 deletions(-) diff --git a/test/fixtures/course_infos.yml b/test/fixtures/course_infos.yml index 79b5cfde7..dfd5db89c 100644 --- a/test/fixtures/course_infos.yml +++ b/test/fixtures/course_infos.yml @@ -1,9 +1,15 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html -one: - typeId: 1 - typeName: MyString +courses_001_infos: + id: 1 + course_id: 1 + user_id: 20 + created_at: 2013-09-30 15:36:00 + updated_at: 2014-04-19 01:50:41 +courses_002_infos: + id: 2 + course_id: 2 + user_id: 20 + created_at: 2013-09-30 15:36:00 + updated_at: 2014-04-19 01:50:41 -two: - typeId: 1 - typeName: MyString diff --git a/test/fixtures/course_statuses.yml b/test/fixtures/course_statuses.yml index 8396c1d54..b2aa0f6f5 100644 --- a/test/fixtures/course_statuses.yml +++ b/test/fixtures/course_statuses.yml @@ -1,15 +1,18 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -one: +courses_001_statuses: changesets_count: 1 watchers_count: 1 course_id: 1 grade: 1.5 course_ac_para: 1 + created_at: 2013-09-30 15:36:00 + updated_at: 2014-04-19 01:50:41 -two: +courses_002_statuses: changesets_count: 1 watchers_count: 1 - course_id: 1 + course_id: 2 grade: 1.5 course_ac_para: 1 + created_at: 2013-09-30 15:36:00 + updated_at: 2014-04-19 01:50:41 diff --git a/test/fixtures/courses.yml b/test/fixtures/courses.yml index 803c14c26..d6cbea59b 100644 --- a/test/fixtures/courses.yml +++ b/test/fixtures/courses.yml @@ -1,23 +1,23 @@ --- -courses_invalid_001: +courses_001: id: 1 - tea_id: - name: '' + tea_id: 20 + name: courses_001 state: code: - time: + time: 2013 extra: - created_at: 2013-09-30 15:36:00.000000000 Z - updated_at: 2014-04-19 01:50:41.000000000 Z + created_at: 2013-09-30 15:36:00 + updated_at: 2014-04-19 01:50:41 location: - term: + term: 春季学期 string: - password: + password: '1234' setup_time: - endup_time: - class_period: - school_id: - description: + endup_time: '2014-04-18 00:00:00' + class_period: '32' + school_id: 117 + description: 'courses_001 description' status: 1 attachmenttype: 2 lft: @@ -25,16 +25,16 @@ courses_invalid_001: is_public: 1 inherit_members: 1 -courses_008: - id: 8 - tea_id: 5 +courses_002: + id: 2 + tea_id: 20 name: 分布式计算环境 state: code: time: 2013 extra: course2013-09-30_23-36-00 - created_at: 2013-09-30 15:36:00.000000000 Z - updated_at: 2014-04-19 01:50:41.000000000 Z + created_at: 2013-09-30 15:36:00 + updated_at: 2014-04-19 01:50:41 location: term: 春季学期 string: @@ -50,129 +50,3 @@ courses_008: rgt: is_public: 1 inherit_members: 1 -courses_058: - id: 58 - tea_id: 1168 - name: 软件工程实践 - state: - code: - time: 2014 - extra: course2014-04-17_17-12-17 - created_at: 2014-04-17 09:12:17.000000000 Z - updated_at: 2014-04-17 09:12:17.000000000 Z - location: - term: 春季学期 - string: - password: SEP2014 - setup_time: - endup_time: - class_period: '18' - school_id: 0 - description: 国防科技大学计算机学院工程硕士专业选修课。 - status: 1 - attachmenttype: 2 - lft: - rgt: - is_public: 1 - inherit_members: 1 -courses_059: - id: 59 - tea_id: 193 - name: 软件项目管理 - state: - code: - time: 2014 - extra: course2014-04-18_18-10-46 - created_at: 2014-04-18 10:10:46.000000000 Z - updated_at: 2014-04-18 10:10:46.000000000 Z - location: - term: 春季学期 - string: - password: software - setup_time: - endup_time: - class_period: '30' - school_id: 0 - description: 面向“软件工程”专业的本科生 - status: 1 - attachmenttype: 2 - lft: - rgt: - is_public: 1 - inherit_members: 1 -courses_060: - id: 60 - tea_id: 1179 - name: android开发 - state: - code: - time: 2014 - extra: course2014-04-19_15-40-39 - created_at: 2014-04-19 07:40:39.000000000 Z - updated_at: 2014-04-19 07:40:39.000000000 Z - location: - term: 春季学期 - string: - password: trustie740208 - setup_time: - endup_time: - class_period: '48' - school_id: 37 - description: '' - status: 1 - attachmenttype: 2 - lft: - rgt: - is_public: 1 - inherit_members: 1 -courses_061: - id: 61 - tea_id: 29 - name: 测试课程1 - state: - code: - time: 2014 - extra: course2014-06-04_14-51-56 - created_at: 2014-06-04 06:51:56.000000000 Z - updated_at: 2014-07-15 01:40:49.000000000 Z - location: - term: 春季学期 - string: - password: '1234' - setup_time: - endup_time: '2014-07-14 00:00:00' - class_period: '23' - school_id: 1579 - description: '233' - status: 1 - attachmenttype: 2 - lft: - rgt: - is_public: 0 - inherit_members: 1 -course_trustie_074: - id: 74 - tea_id: 698 - name: 电路与电子学基础(软件工程专业) - state: - code: - time: 2014 - extra: course2014-05-22_16-09-25 - created_at: 2014-05-22 08:09:25.000000000 Z - updated_at: 2014-05-22 08:09:25.000000000 Z - location: - term: 春季学期 - string: - password: '12345678' - setup_time: - endup_time: - class_period: '54' - school_id: 117 - description: "电路与电子学基础,软件工程小班\\r\ 模拟电子技术部分\ " - status: 1 - attachmenttype: 2 - lft: - rgt: - is_public: 1 - inherit_members: 1 - diff --git a/test/fixtures/member_roles.yml b/test/fixtures/member_roles.yml index 79a8a8530..999985395 100644 --- a/test/fixtures/member_roles.yml +++ b/test/fixtures/member_roles.yml @@ -47,8 +47,3 @@ 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 7f918f683..10d52f300 100644 --- a/test/fixtures/members.yml +++ b/test/fixtures/members.yml @@ -60,10 +60,3 @@ 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/schools.yml b/test/fixtures/schools.yml index 953c725bf..fb97019ca 100644 --- a/test/fixtures/schools.yml +++ b/test/fixtures/schools.yml @@ -1,9 +1,13 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html -one: - name: - province: MyString +school_117: + id: 117 + name: 国防科学技术大学 + province: 湖南省 + logo_link: -two: - name: - province: MyString +school_001: + id: 1 + name: 摧毁地球人学校 + province: 火星 + logo_link: diff --git a/test/fixtures/user_extensions.yml b/test/fixtures/user_extensions.yml index 8c19ad7b1..94ee5d0e0 100644 --- a/test/fixtures/user_extensions.yml +++ b/test/fixtures/user_extensions.yml @@ -1,76 +1,57 @@ -person_one_extra: - id: 44 - user_id: 29 - birthday: "2013-09-30 21:19:25" - brief_introduction: nil - gender: 1 - location: "江苏" - occupation: "" - work_experience: nil - zip_code: nil - created_at: "2013-09-30 21:19:25" - updated_at: "2013-10-09 19:00:06" - technical_title: nil - identity: 2 - student_id: nil - teacher_realname: nil - student_realname: nil - location_city: "南京" - -person_mao_extra: - id: 22 - user_id: 193 - birthday: "2013-09-30 21:19:25" - brief_introduction: "期待..." - gender: 0 - location: "湖南长沙" - occupation: "国防科技大学计算机学院" - work_experience: nil - zip_code: nil - created_at: "2013-09-30 21:19:25" - updated_at: "2013-10-09 19:00:06" - technical_title: "教授" - identity: 0 - student_id: nil - teacher_realname: nil - student_realname: nil - location_city: nil -ue_lirongzhen: - id: 587 - user_id: 642 +user_extension_006: + id: 6 + user_id: 6 birthday: brief_introduction: gender: 0 - location: 河南 + location: + occupation: + work_experience: + zip_code: + created_at: 2014-07-29 02:54:09 + updated_at: 2014-07-29 02:54:09 + technical_title: + identity: 0 + student_id: + teacher_realname: + student_realname: + location_city: + school_id: +user_extension_020: + id: 20 + user_id: 20 + birthday: + brief_introduction: 哈尔 + gender: 0 + location: 黑龙江 occupation: kylinos-cloud work_experience: zip_code: - created_at: 2014-03-18 14:52:55.000000000 Z - updated_at: 2014-03-26 07:19:04.000000000 Z - technical_title: - identity: 1 - student_id: '14066023' + created_at: 2014-07-29 02:54:09 + updated_at: 2014-07-29 02:54:09 + technical_title: 助教 + identity: 0 + student_id: teacher_realname: student_realname: - location_city: 周口 + location_city: 哈尔滨 school_id: -ue_yingang: - id: 6 - user_id: 5 +user_extension_025: + id: 25 + user_id: 25 birthday: - brief_introduction: 现有功能的精细化! + brief_introduction: 哈尔 gender: 0 - location: 湖南 - occupation: 国防科学技术大学计算机学院 + location: 黑龙江 + occupation: kylinos-cloud work_experience: zip_code: - created_at: 2013-09-24 09:36:12.000000000 Z - updated_at: 2014-04-19 08:16:55.000000000 Z - technical_title: 副教授 - identity: 0 - student_id: '' + created_at: 2014-07-29 02:54:09 + updated_at: 2014-07-29 02:54:09 + technical_title: 助教 + identity: 1 #student + student_id: 10060342 teacher_realname: - student_realname: - location_city: 长沙 + student_realname: 'ue_realname' + location_city: 哈尔滨 school_id: 117 - diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index cf7f6da7c..48aa9c0da 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -72,7 +72,7 @@ users_003: login: dlopper type: User users_005: - id: 12 + id: 5 created_on: 2006-07-19 19:33:19 +02:00 # Locked status: 3 @@ -165,26 +165,27 @@ groups_011: id: 11 lastname: B Team type: Group -users_yingang_teacher: - id: 5 - login: jacknudt - hashed_password: dbbd96684c9a64afe9c4935ce0b517e5e9c08064 - firstname: 刚 - lastname: 尹 - mail: jack_nudt@163.com +users_020: + id: 20 + login: teacher1 + # password: foobar + hashed_password: 6b6095d977621a3071ae2670be95b88092e94b53 + firstname: wang + lastname: dr + mail: jack_nudt@foo.bar admin: false status: 1 - last_login_on: 2014-04-27 13:49:18.000000000 Z + last_login_on: 2014-07-29 02:54:09 language: zh auth_source_id: - created_on: 2013-06-25 05:20:59.000000000 Z - updated_on: 2014-07-16 03:37:51.000000000 Z + created_on: 2014-07-29 02:54:09 + updated_on: 2014-07-29 02:54:09 type: User identity_url: mail_notification: only_my_events - salt: 92944df2ce4dae1a4f01007263c5d8bb -users_lirongzhen_student: - id: 642 + salt: 9db798ee4c462d9614479e6738790891 +users_025: + id: 25 login: lirongzhen hashed_password: 070922b015398577c3ae0d87a68d5ffa93bf82e9 firstname: 荣振 diff --git a/test/functional/courses_controller_test.rb b/test/functional/courses_controller_test.rb index 7185f6303..b905b5038 100644 --- a/test/functional/courses_controller_test.rb +++ b/test/functional/courses_controller_test.rb @@ -1,7 +1,18 @@ require File.expand_path('../../test_helper', __FILE__) class CoursesControllerTest < ActionController::TestCase - fixtures :courses, :users, :user_extensions, :roles, :members, :member_roles, :enabled_modules, :boards, :messages + fixtures :courses, + :course_infos, + :course_statuses, + :users, + :user_extensions, + :schools, + :roles, + :members, + :member_roles, + :enabled_modules, + :boards, + :messages def setup @request.session[:user_id] = nil @@ -23,7 +34,7 @@ class CoursesControllerTest < ActionController::TestCase # Get :new # 人员添加课程的权限是不属于任何角色 def test_new_course_anyone_temporary - @request.session[:user_id] = 5 + @request.session[:user_id] = 20 Role.find_by_name("Non member").add_permission! :add_course #Non member get :new @@ -33,7 +44,7 @@ class CoursesControllerTest < ActionController::TestCase # post :create def test_create_course_with_access_control - @request.session[:user_id] = 5 + @request.session[:user_id] = 20 Role.find_by_name("Non member").add_permission! :add_course #Non member course_name = 'course_one' @@ -59,7 +70,7 @@ class CoursesControllerTest < ActionController::TestCase # post :create 403 def test_create_course_without_access_control - @request.session[:user_id] = 5 + @request.session[:user_id] = 20 #Role.find_by_name("Non member").add_permission! :add_course #Non member course_name = 'course_one'