2017-01-01 17:00:27 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe MissionsController, type: :controller do
|
|
|
|
|
2017-01-01 19:21:34 +08:00
|
|
|
# describe "GET #getlist" do
|
|
|
|
|
|
|
|
# it "return a valid json format of missions" do
|
|
|
|
|
|
|
|
# register = create(:user)
|
|
|
|
# user = User.find_by(email: register.email)
|
|
|
|
# session[:user_id] = user.id
|
|
|
|
|
|
|
|
# user1 = create(:user)
|
|
|
|
# user2 = create(:user)
|
|
|
|
# params = {name: "project addUsers test",content: "addUsers test"}
|
|
|
|
# project = Project.new(params)
|
|
|
|
# project.users << register
|
|
|
|
# project.save
|
|
|
|
|
|
|
|
# params_mission = {name: "mission1",content: "mission content",deadline:"2016-10-17 10:00:00",priority:1,status:1,project_id: project.id}
|
|
|
|
# params_mission2 = {name: "mission2",content: "mission content2",deadline:"2016-10-17 10:00:00",priority:1,status:2,project_id: project.id}
|
|
|
|
# mission = Mission.new(params_mission)
|
|
|
|
# mission2 = Mission.new(params_mission2)
|
|
|
|
# mission.save
|
|
|
|
# mission2.save
|
|
|
|
# get :getlist,project_id: project.id,status_type: 1
|
|
|
|
|
|
|
|
# puts response.body
|
|
|
|
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# describe "GET #detail" do
|
|
|
|
|
|
|
|
# it "return a correct json format detail" do
|
|
|
|
|
|
|
|
# register = create(:user)
|
|
|
|
# params = {name: "project addUsers test",content: "addUsers test"}
|
|
|
|
# project = Project.new(params)
|
|
|
|
# project.users << register
|
|
|
|
# project.save
|
|
|
|
|
|
|
|
# params_mission = {name: "mission1",content: "mission content",deadline:"2016-10-17 10:00:00",priority:1,status:1,project_id: project.id}
|
|
|
|
# params_mission2 = {name: "mission2",content: "mission content2",deadline:"2016-10-17 10:00:00",priority:1,status:2,project_id: project.id}
|
|
|
|
# mission = Mission.new(params_mission)
|
|
|
|
# mission.save
|
|
|
|
# get :detail,id: mission.id
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
describe "POST #comments" do
|
|
|
|
|
|
|
|
it "can publish comments successfully" do
|
|
|
|
|
|
|
|
|
|
|
|
register = create(:user)
|
|
|
|
params = {name: "project addUsers test",content: "addUsers test"}
|
|
|
|
project = Project.new(params)
|
|
|
|
project.users << register
|
|
|
|
project.save
|
|
|
|
|
|
|
|
params_mission = {name: "mission1",content: "mission content",deadline:"2016-10-17 10:00:00",priority:1,status:1,project_id: project.id}
|
|
|
|
params_mission2 = {name: "mission2",content: "mission content2",deadline:"2016-10-17 10:00:00",priority:1,status:2,project_id: project.id}
|
|
|
|
mission = Mission.new(params_mission)
|
|
|
|
mission.save
|
|
|
|
|
2017-01-01 19:35:07 +08:00
|
|
|
post :comments , mission_id: mission.id,content: "用户评论"
|
|
|
|
|
2017-01-01 19:21:34 +08:00
|
|
|
puts "hello world"
|
|
|
|
puts response.body
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2017-01-01 17:00:27 +08:00
|
|
|
|
|
|
|
end
|