ambition/spec/controllers/shares_controller_spec.rb

56 lines
1.6 KiB
Ruby

require 'rails_helper'
RSpec.describe SharesController,type: :controller do
describe "POST #create" do
it "create a correct share" do
register = create(:user)
user = User.find_by(email: register.email)
session[:user_id] = user.id
params = {name: "project addUsers test",content: "addUsers test"}
project = Project.new(params)
project.users << register
project.save
post :create,project_id: project.id,content: "苟利国家生死以,岂因福祸避趋之"
end
end
describe "GET #getShareList" do
it "return correct share list" do
register = create(:user)
user = User.find_by(email: register.email)
session[:user_id] = user.id
params = {name: "project test",content: " test"}
project = Project.new(params)
project.users << register
project.save
post :create,project_id: project.id,content: "苟利国家生死以,岂因福祸避趋之"
post :create,project_id: project.id,content: "too young too simple"
post :create,project_id: project.id,content: "too young too naive"
get :getShareList,project_id: project.id
puts response.body
end
end
end