This commit is contained in:
parent
847bb35906
commit
281c48c0b3
|
@ -494,7 +494,7 @@ class CoursesController < ApplicationController
|
|||
if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] ))
|
||||
render :layout => 'base_courses'
|
||||
else
|
||||
render_404
|
||||
render_403
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
---
|
||||
biding_project_001:
|
||||
id: 1
|
||||
project_id: -1
|
||||
bid_id: 1
|
||||
|
||||
#biding_project_002:
|
|
@ -0,0 +1,34 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
---
|
||||
homework_001:
|
||||
id: 1
|
||||
author_id: 20
|
||||
budget: "0"
|
||||
commit: 3
|
||||
deadline: "2014-05-30"
|
||||
description: ""
|
||||
homework_type: 1
|
||||
is_evaluation:
|
||||
name: "course_001_homework_001"
|
||||
parent_id:
|
||||
password:
|
||||
proportion: 60
|
||||
reward_type: 3 # 作业
|
||||
updated_on: 2014-05-23 08:15:28
|
||||
created_on: 2014-05-23 08:15:28
|
||||
homework_002:
|
||||
id: 2
|
||||
author_id: 20
|
||||
budget: "0"
|
||||
commit: 3
|
||||
deadline: "2014-05-30"
|
||||
description: ""
|
||||
homework_type: 1
|
||||
is_evaluation:
|
||||
name: "course_001_homework_002"
|
||||
parent_id:
|
||||
password:
|
||||
proportion: 60
|
||||
reward_type: 3 # 作业
|
||||
updated_on: 2014-05-23 08:15:28
|
||||
created_on: 2014-05-23 08:15:28
|
|
@ -0,0 +1,10 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
---
|
||||
homework_for_courses_001:
|
||||
id: 1
|
||||
course_id: 1
|
||||
bid_id: 1
|
||||
homework_for_courses_002:
|
||||
id: 2
|
||||
course_id: 1
|
||||
bid_id: 2
|
|
@ -28,6 +28,38 @@ jfm_002:
|
|||
m_reply_count:
|
||||
m_reply_id:
|
||||
is_comprehensive_evaluation:
|
||||
jfm_003:
|
||||
# Course one's jfm
|
||||
id: 3
|
||||
jour_id: 1
|
||||
jour_type: Course
|
||||
user_id: 2
|
||||
notes:
|
||||
status:
|
||||
reply_id: 0
|
||||
created_on: 2014-07-16 15:27:2
|
||||
updated_on: 2014-07-16 15:27:2
|
||||
m_parent_id:
|
||||
is_readed:
|
||||
m_reply_count:
|
||||
m_reply_id:
|
||||
is_comprehensive_evaluation:
|
||||
jfm_004:
|
||||
# Course one's jfm
|
||||
id: 4
|
||||
jour_id: 1
|
||||
jour_type: Course
|
||||
user_id: 25
|
||||
notes: course_001的留言by_user_025
|
||||
status:
|
||||
reply_id: 0
|
||||
created_on: 2014-07-16 15:27:2
|
||||
updated_on: 2014-07-16 15:27:2
|
||||
m_parent_id:
|
||||
is_readed:
|
||||
m_reply_count:
|
||||
m_reply_id:
|
||||
is_comprehensive_evaluation:
|
||||
jfm_045:
|
||||
id: 45
|
||||
jour_id: 2
|
||||
|
|
|
@ -6,6 +6,9 @@ class CoursesControllerTest < ActionController::TestCase
|
|||
:course_statuses,
|
||||
:users,
|
||||
:user_extensions,
|
||||
:bids,
|
||||
:homework_for_courses,
|
||||
:journals_for_messages,
|
||||
:schools,
|
||||
:roles,
|
||||
:members,
|
||||
|
@ -88,6 +91,52 @@ class CoursesControllerTest < ActionController::TestCase
|
|||
|
||||
assert_response :forbidden
|
||||
end
|
||||
test ':homework get by non-member is access' do
|
||||
get :homework, {id: 1}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test ':feedback Get by non-member is access' do
|
||||
get :feedback, {id: 1}
|
||||
assert_response :success
|
||||
# 检测留言是否在其中以及不报错
|
||||
jfms = JournalsForMessage.where(jour_type: 'Course', jour_id: 1, m_parent_id: nil).reorder('id DESC')
|
||||
jfms.take(5).each do |j|
|
||||
assert_select "li#word_li_#{j.id}"
|
||||
end
|
||||
end
|
||||
|
||||
test ':homework get by non-member' do
|
||||
get :homework, {id: 1}
|
||||
assert_response :success
|
||||
course = Course.find(1)
|
||||
assert course.homeworks.any?
|
||||
course.homeworks.each do |homework|
|
||||
assert_select '.bid_path', homework.name
|
||||
end
|
||||
end
|
||||
|
||||
test ':new_homework by no user should not new_homework course_001' do
|
||||
get :new_homework, {id: 1}
|
||||
assert_response 403
|
||||
end
|
||||
test ':new_homework by loged & allowed user should get new_homework course_001' do
|
||||
user_id = 25
|
||||
member = Member.create(user_id: user_id, project_id: -1, course_id: 1, roles: [Role.last])
|
||||
MemberRole.create(member_id: member.id, role_id: 3)
|
||||
@request.session[:user_id] = user_id
|
||||
get :new_homework, {id: 1}
|
||||
assert_response :success
|
||||
assert_template 'new_homework'
|
||||
end
|
||||
|
||||
test ':member by ano' do
|
||||
get :member, {id: 1}
|
||||
assert_response :success
|
||||
assert_template 'member'
|
||||
assert assigns(:members).any?
|
||||
end
|
||||
|
||||
|
||||
# test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
|
||||
# @request.session[:user_id] = 3
|
||||
|
|
Loading…
Reference in New Issue