Merge branch 'guange_dev' into szzh

This commit is contained in:
sw 2015-05-15 16:14:59 +08:00
commit d6599cd1b0
26 changed files with 1674 additions and 1558 deletions

View File

@ -315,7 +315,7 @@ class AccountController < ApplicationController
#根据home_url生产正则表达式
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && last_login_on != ''
redirect_to user_activities_path(user,host: Setting.user_domain)
redirect_to user_activities_path(user,host: Setting.host_user)
else
if last_login_on == ''
redirect_to my_account_url
@ -333,7 +333,7 @@ class AccountController < ApplicationController
token = Token.get_or_create_permanent_login_token(user)
cookie_options = {
:value => token.value,
:expires => 7.days.from_now,
:expires => 1.month.from_now,
:path => (Redmine::Configuration['autologin_cookie_path'] || '/'),
:secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
:httponly => true

View File

@ -852,7 +852,7 @@ class CoursesController < ApplicationController
#验证是否显示课程
def can_show_course
@first_page = FirstPage.find_by_page_type('project')
if @first_page.show_course == 2
if @first_page.try(:show_course) == 2
render_404
end
end

View File

@ -118,11 +118,11 @@ module ApplicationHelper
end
#if user.active? || (User.current.admin? && user.logged?)
# link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
# link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => user.css_classes
#else
# name
#end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => user.css_classes
else
h(user.to_s)
end
@ -131,7 +131,7 @@ module ApplicationHelper
def link_to_isuue_user(user, options={})
if user.is_a?(User)
name = h(user.name(options[:format]))
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => "pro_info_p"
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => "pro_info_p"
else
h(user.to_s)
end
@ -140,7 +140,7 @@ module ApplicationHelper
def link_to_settings_user(user, options={})
if user.is_a?(User)
name = h(user.name(options[:format]))
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => "w90 c_orange fl"
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => "w90 c_orange fl"
else
h(user.to_s)
end
@ -155,7 +155,7 @@ module ApplicationHelper
else
name = user.login
end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => options[:class]
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => options[:class]
else
h(user.to_s)
end
@ -2076,21 +2076,21 @@ module ApplicationHelper
hidden_non_project = Setting.find_by_name("hidden_non_project")
visiable = !(hidden_non_project && hidden_non_project.value == "0")
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain}
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.host_course}
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.host_name}
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.host_contest}
# course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'}
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain}
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.host_course}
# courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'}
#users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain}
#users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.host_user}
# contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'}
bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'}
forum_link = link_to l(:label_forum_all), {:controller => "forums", :action => "index"}
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'}
project_new_link = link_to l(:label_project_new), {:controller => 'projects', :action => 'new', :host => Setting.project_domain}
# project_mine_link = link_to l(:label_my_project), {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
project_new_link = link_to l(:label_project_new), {:controller => 'projects', :action => 'new', :host => Setting.host_name}
# project_mine_link = link_to l(:label_my_project), {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
#@nav_dispaly_project_label
nav_list = Array.new

View File

@ -11,7 +11,7 @@ module GitlabHelper
PROJECT_PATH_CUT = 40
# gitlab版本库所在服务器
# 注意REPO_IP_ADDRESS必须以http://开头暂时只支持HTTP协议未支持SSH
#REPO_IP_ADDRESS = "http://" + Setting.repository_domain
#REPO_IP_ADDRESS = "http://" + Setting.host_repository
REPO_IP_ADDRESS = "http://192.168.137.100"
GITLAB_API = "/api/v3"

View File

@ -24,7 +24,7 @@ module RepositoriesHelper
ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/"
end
PROJECT_PATH_CUT = 40
REPO_IP_ADDRESS = Setting.repository_domain
REPO_IP_ADDRESS = Setting.host_repository
def format_revision(revision)
if revision.respond_to? :format_identifier

View File

@ -187,7 +187,7 @@
<!-- modified by longjun -->
<%= link_to l(:label_create_new_projects),
new_project_path(:course => 0, :project_type => 0, :host => Setting.project_domain),
new_project_path(:course => 0, :project_type => 0, :host => Setting.host_name),
:target => '_blank'
%>
<!-- end longjun -->

View File

@ -169,15 +169,15 @@ function cookieget(n)
<div class="side_center">
<div class="custom_service">
<% get_memo %>
<% if @public_forum %>
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %>
<%= f.text_area :subject,:id=>"subject", :class => "opnionText", :placeholder => l(:label_feedback_tips) %>
<%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %>
<label class="c_grey">您还能输入<span id="textCount" class="c_orange">50</span>个字符</label>
<a href="javascript:void(0);" class="opnionButton" style=" color:#fff;" id="" onclick="f_submit();"><%= l(:label_submit)%></a>
<% end %>
<% end %>
<% if @public_forum %>
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %>
<%= f.text_area :subject,:id=>"subject", :class => "opnionText", :placeholder => l(:label_feedback_tips) %>
<%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %>
<label class="c_grey">您还能输入<span id="textCount" class="c_orange">50</span>个字符</label>
<a href="javascript:void(0);" class="opnionButton" style=" color:#fff;" id="" onclick="f_submit();"><%= l(:label_submit)%></a>
<% end %>
<% end %>
</div>
<div class="msgserver">
<a href="http://user.trustie.net/users/34/user_newfeedback" style="color: #15BCCF;"><%= l(:label_technical_support) %>白&nbsp;&nbsp;&nbsp;羽</a>

View File

@ -27,13 +27,13 @@
<% end %>
<%= render :partial => 'layouts/user_project_list', :locals => {:hasCourse => hasCourse} %>
<li style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li>
</ul>
</li>
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;">
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')',
{ :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.user_domain },
{ :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user },
{:class => 'my-message'} if User.current.logged?%>
</li>
</ul>

View File

@ -67,17 +67,17 @@ end
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%=User.current%> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')', { :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.user_domain }, {:class => 'my-message'} if User.current.logged? -%>
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')', { :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user }, {:class => 'my-message'} if User.current.logged? -%>
</li>
<li>
<%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %>
<%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.host_course} %>
</li>
<li>
<%=link_to l(:label_my_projects),{:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<%=link_to l(:label_my_projects),{:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
</li>
<li class="divider"></li>
<li>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li>
</ul>
</li>

View File

@ -18,15 +18,15 @@
<% if User.current.logged? -%>
<li id="current_user_li">
<%= link_to "#{User.current.login}<span class='pic_triangle'></span>".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.user_domain}, :class => "uses_name"%>
<%= link_to "#{User.current.login}<span class='pic_triangle'></span>".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.host_user}, :class => "uses_name"%>
<ul id="user_sub_menu" style="right: 0px;display: none;">
<% unless User.current.projects.empty? %>
<li id="my_projects_li">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain}, :class => "parent" %>
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name}, :class => "parent" %>
<ul id="my_projects_ul">
<% User.current.projects.each do |project| %>
<li title="<%=project.name%>">
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %>
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name } %>
</li>
<% end %>
</ul>
@ -49,7 +49,7 @@
<% end %>
<% end %>
<li>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li>
</ul>
</li>

View File

@ -1,10 +1,10 @@
<% if User.current.projects.count>0 %>
<li id="project_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
<ul class="project_sub_menu" style="top:<%= hasCourse ? 35 : 0 %>px;">
<% User.current.projects.each do |project| %>
<li style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%=project.name%>">
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %>
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name } %>
</li>
<% end %>
</ul>

View File

@ -34,7 +34,7 @@
<% memberships = user.memberships.all(:conditions => cond) %>
<%= l(:label_x_contribute_to, :count => memberships.count) %>
<% for member in memberships %>
<%= link_to member.project.name, {:controller => 'projects', :action => 'show',id: member.project.id, host: Setting.project_domain } %><%= (memberships.last == member) ? '' : '' %>
<%= link_to member.project.name, {:controller => 'projects', :action => 'show',id: member.project.id, host: Setting.host_name } %><%= (memberships.last == member) ? '' : '' %>
<% end %>
<p>
<%# unless user.memberships.empty? %>
@ -45,7 +45,7 @@
<%= "" unless user_courses.empty? %>
<% for course in user_courses %>
<%# if course.name != nil %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<%# end %>
<% end %>
<%# end %>

View File

@ -32,7 +32,7 @@
<%= l(:label_x_course_contribute_to, :count => user_courses.count) %>
<%= "" unless user_courses.empty? %>
<% for course in user_courses %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<% end %>
</p>
</td>

View File

@ -38,7 +38,7 @@
<%= "" unless user_courses.empty? %>
<% for course in user_courses %>
<%# if course.name != nil %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<%# end %>
<% end %>
<%# end %>

View File

@ -254,16 +254,6 @@ tags_max_length:
tags_show_search_results:
format: int
default: 5
user_domain:
default: user.trustie.net
project_domain:
default: forge.trustie.net
contest_domain:
default: contest.trustie.net
course_domain:
default: course.trustie.net
repository_domain:
default: repository.trustie.net
please_chose:
default: 请选择
hidden_non_project:

View File

@ -0,0 +1,8 @@
class AddHostConfigToSettings < ActiveRecord::Migration
def change
Setting.create(name: 'host_course', value: 'course.trustie.net')
Setting.create(name: 'host_contest', value: 'contest.trustie.net')
Setting.create(name: 'host_user', value: 'user.trustie.net')
Setting.create(name: 'host_repository', value: 'repository.trustie.net')
end
end

File diff suppressed because it is too large Load Diff

View File

@ -267,7 +267,7 @@ Redmine::AccessControl.map do |map|
end
#by young
Redmine::MenuManager.map :top_menu do |menu|
menu.push :home, {:host => Setting.user_domain}
menu.push :home, {:host => Setting.host_user}
menu.push :course_practice, {:controller => 'projects', :action => 'course', :project_type => 1}
menu.push :project_deposit, { :controller => 'projects', :action => 'index', :project_type => 0}, :caption => :label_project_deposit
menu.push :software_user, {:controller => 'users', :action => 'index'}
@ -336,7 +336,7 @@ end
########fq
Redmine::MenuManager.map :bid_menu do |menu|
menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_user_response
menu.push :project, { :controller => 'bids', :action => 'show_project', :host => Setting.project_domain }, :caption => :label_bidding_project
menu.push :project, { :controller => 'bids', :action => 'show_project', :host => Setting.host_name }, :caption => :label_bidding_project
# menu.push :result, { :controller => 'bids', :action => 'show_results' },
# :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p }
end
@ -422,7 +422,7 @@ Redmine::MenuManager.map :course_menu do |menu|
end
Redmine::MenuManager.map :user_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain }
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_user }
menu.push :user_course, {:controller => 'users', :action => 'user_courses'},
:if => Proc.new {|u| if User.current == u || User.current.admin?
membership = u.coursememberships.all
@ -432,7 +432,7 @@ Redmine::MenuManager.map :user_menu do |menu|
FirstPage.find_by_page_type('project').show_course != 2 && membership && membership.count > 0
}
#menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang
menu.push :user_project, {:controller => 'users', :action => 'user_projects_index', :host => Setting.project_domain},
menu.push :user_project, {:controller => 'users', :action => 'user_projects_index', :host => Setting.host_name},
:if => Proc.new {|u| if User.current.admin?
memberships = u.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first
else
@ -443,24 +443,24 @@ Redmine::MenuManager.map :user_menu do |menu|
memberships || watch_projects
}
# menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end
Redmine::MenuManager.map :user_enterprise_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain }
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_user }
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end
Redmine::MenuManager.map :user_menu_self do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.project_domain }
menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.user_domain}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_name }
menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.host_user}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end
#end

View File

@ -2780,4 +2780,4 @@ div.repos_explain{
padding-top: 20px;
padding-bottom: 20px;
}
.upload_img img{max-width: 580px;}
.upload_img img{max-width: 580px;width: 100%;}

13
spec/factories/courses.rb Normal file
View File

@ -0,0 +1,13 @@
FactoryGirl.define do
factory :course do
name '课程名'
time '2015'
term '春季课程'
period 1
password '111'
description '课程描述'
is_public 1
open_student 1
association :teacher, factory: :user
end
end

View File

@ -1,9 +1,9 @@
FactoryGirl.define do
factory :user do
login "ExampleUser"
login "factoryuser"
mail "user@example.com"
password "foobar"
password_confirmation "foobar"
password "foobar111"
password_confirmation "foobar111"
end
end

View File

@ -1,6 +1,22 @@
require 'rails_helper'
require 'shared_account_spec'
RSpec.describe "Account request", :type => :request do
describe "注册用户" do
include_context "create user"
it "正常注册可以成功" do
shared_register
expect(response).to redirect_to(my_account_url)
end
it "修改用户资料" do
shared_register
shared_update_user
expect(response).to redirect_to(user_url(session[:user_id]))
end
end
describe "用户登录" do
let(:user){FactoryGirl.create(:user)}
@ -10,7 +26,7 @@ RSpec.describe "Account request", :type => :request do
end
context "正常登录" do
before{post signin_path, username: user.login, password: user.password}
before{ post signin_path, username: user.login, password: user.password }
it "登录成功,正常跳转" do
expect(response).to redirect_to(my_account_url)
end

View File

@ -0,0 +1,46 @@
require 'rails_helper'
require 'shared_account_spec'
RSpec.describe "课程", :type => :request do
let(:course){FactoryGirl.attributes_for(:course)}
describe "创建课程" do
include_context "create user"
before {
shared_register
shared_update_user
}
context "参数正确,成功创建课程" do
before{
uu = current_user
allow(User).to receive(:current).and_return(uu)
allow(uu).to receive(:allowed_to?).and_return(123)
post courses_path,
"course[name]"=> course[:name],
"class_period"=> course[:period],
"time"=> course[:time],
"term"=> course[:term],
"course[password]"=>course[:password],
"course[description]"=> course[:description],
"course[is_public]"=> course[:is_public],
"course[open_student]"=> course[:open_student]
}
it{
puts User.current.allowed_to?(1,2)
binding.pry
}
it{expect(response).to have_http_status(:success)}
it{expect(assigns(:course)).to be_a_new(Course)}
it{expect(response).to redirect_to(course_url(assigns(:course)))}
end
end
describe "配置课程" do
context "修改课程图片" do
it "正常图片上传成功" do
end
it "不是图片,上传失败"
end
end
end

View File

@ -0,0 +1,6 @@
require 'rails_helper'
RSpec.describe "作业打包下载", :type => :request do
describe "单独下载某学生作业" do
end
end

0
spec/seeds.rb Normal file
View File

View File

@ -0,0 +1,42 @@
require 'rails_helper'
RSpec.shared_context "create user" do
let(:user) {FactoryGirl.attributes_for(:user)}
def shared_register
post register_path, user: user
end
def shared_update_user
post my_account_url,
login: user[:login],
identity: 0,
technical_title: "教授",
no: '',
"user[lastname]" => 'lastname',
"user[firstname]" => 'firstname',
enterprise_name: '',
gender: 1,
province: '',
occupation: "",
"user[mail]" => user[:mail],
"user[language]" => "zh",
province: '',
city: '',
"user[mail_notification]" => "all",
"user_extensions[birthday]" => '',
"user_extensions[gender]" => 1,
"user_extensions[brief_introduction]" => '',
"user_extensions[location]" => '',
"user_extensions[occupation]" => '',
"user_extensions[work_experience]" => '',
"user_extensions[zip_code]" => ''
end
def shared_login
post signin_path, username: user[:login], password: user[:password]
end
def current_user
User.find(session[:user_id])
end
end