ambition/spec/controllers/missions_controller_spec.rb

79 lines
2.9 KiB
Ruby

require 'rails_helper'
RSpec.describe MissionsController, type: :controller do
# 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
post :comments , mission_id: mission.id,content: "用户评论"
puts "hello world"
puts response.body
end
end
end