From d32c4c8e861be5b8aa42c86236225c0ce7f29e62 Mon Sep 17 00:00:00 2001 From: zhuhao Date: Tue, 27 Jan 2015 15:32:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=A2=84=E5=88=B6=E4=BB=B6gem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index dc834e68d..df019a5ad 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,7 @@ group :test do gem 'factory_girl', '~> 4.4.0' gem 'selenium-webdriver', '~> 2.42.0' - + gem "faker" # platforms :mri, :mingw do # group :rmagick do # # RMagick 2 supports ruby 1.9 From 6a49d7a04fc665f74ee45949a60b55dcfdcd4b87 Mon Sep 17 00:00:00 2001 From: zhuhao Date: Tue, 27 Jan 2015 15:34:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=8C=BF=E5=90=8D?= =?UTF-8?q?=E5=92=8C=E7=94=A8=E6=88=B7=E5=85=A8=E5=90=8D=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/models/user_spec.rb | 90 +++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 6b8c962bd..d400dae80 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,23 +1,24 @@ require 'spec_helper' describe User do - #测试数据验证 - # before { @user = User.new(login: "ExampleUser" ,mail: "user@example.com", - # password: "foobar",password_confirmation: "foobar" ) } + # 测试数据验证 + # 此处采用预构件的方式生成数据 + # it "has a valid facrtory" do + # expect(FactoryGirl.create(:user)).not_to be_valid + # end + before :each do - @user = User.new(login: "ExampleUser" ,mail: "user@example.com", - password: "foobar",password_confirmation: "foobar" ) + @user = User.new(login: 'ExampleUser',firstname: 'sanfeng',lastname: 'zhang' ,mail: 'user@example.com', + password: 'foobar',password_confirmation: 'foobar' ) end - subject { @user }#指定@user为测试对象 - #属性存在性的测试 + + # 指定@user为测试对象 + subject { @user } + # 属性存在性的测试 it { should respond_to(:login) } it { should respond_to(:mail) } - #此处采用与构建的方式生成数据 - # it"is invalid without login" do - # user=FactoryGirl.build(:user,login: nil) - # expect(user).to_not be_valid - # end - #用户名唯一性的测试 + + # 用户名唯一性的测试 describe "when login is already taken" do before do user_with_same_login=@user.dup @@ -29,11 +30,12 @@ describe User do # end end - #邮箱唯一性测试 + # 邮箱唯一性测试 describe "when mail address is already taken " do before do - user_with_same_mail=@user.dup#dup method copy mail - user_with_same_mail.mail=@user.mail.upcase#转大写 + #dup method copy mail + user_with_same_mail=@user.dup + user_with_same_mail.mail=@user.mail.upcase user_with_same_mail.save end it{should_not be_valid} @@ -48,10 +50,10 @@ describe User do #login长度测试(login最大25字符) describe "when the login is too long " do - before{@user.login='a'*25} - it{should be_valid} + before{@user.login='a'*26} + it{should_not be_valid} end - #姓和名的长度测试 + # 姓和名的长度测试 describe "when the first name is too long " do before{@user.firstname='a'*30} it{should_not be_valid} @@ -61,7 +63,7 @@ describe User do it{should_not be_valid} end - #login合法性的测试(符合正则表达式规则的用户名:数字英文) + # login合法性的测试(符合正则表达式规则的用户名:数字英文) describe "when login format is invalid" do it"should be invalid" do username=%w[aa!3 aaa%$&*! 1111==!] @@ -82,7 +84,7 @@ describe User do end end - #邮箱合法性测试,在模型user中邮箱使用了正则表达式 + # 邮箱合法性测试,在模型user中邮箱使用了正则表达式 describe "is the mail valid" do context "when mail format is invalid" do it"should be invalid" do @@ -104,37 +106,39 @@ describe User do end end end - - describe "when the mail is too long" do#邮箱长度验证的测试 + # 邮箱长度验证的测试 + describe "when the mail is too long" do before{@user.mail='a'*60} it{should_not be_valid} end - #验证两次输入的密码是否一致的测试 + # 验证两次输入的密码是否一致的测试 describe "when the password does not match confirmation" do before{@user.password_confirmation="admin123"} it{should_not be_valid} end - #调用相关方法是否能返回期待的结果 - #userInfo方法,选择项目成员时显示的用户信息的文字 - describe "returns the user info when choice the members of the project" do - context "第一种情况" do - @user=User.new() - expect(@user.userInfo).to eq '' - end - context "二种情况" do - @user=User.new() - expect(@user.userInfo).to eq '' - end + # 选择项目成员时显示的用户信息文字userInfo方法的测试 + # describe "when choice the peoject number show the user info" do + # before{ @userwd = User.new(login: 'wudang',firstname: 'sanfeng',lastname: 'zhang' ,mail: 'user@example.com', + # password: 'foobar',password_confirmation: 'foobar' )} + # it "when the firstname and lastname is nil " do + # expect(@userwd.userInfo).to eq 'wudang (zhang sanfeng)' + # end + # + # end + # 返回用户全名的测试 + it "return full user's name" do + expect(@user.show_name).to eq 'zhangsanfeng' + end + + # 返回匿名用户方法的测试 + # User调用其类方法anonymous,返回一个AnonymousUser的实例对象@anonymoususer + # 该对象的lastname属性被赋值为"Anonymous",最后对比其值是否相等 + it "return the anonymous user" do + @anonymoususer=AnonymousUser.new + @anonymoususer=User.anonymous + expect(@anonymoususer.lastname).to eq 'Anonymous' end - # def name - # [firstname, lastname].join(' ') - # end - # it "returns a contact's full name as a string" do - # contact = Contact.new(firstname: 'John', lastname: 'Doe', - # email: 'johndoe@example.com') - # expect(contact.name).to eq 'John Doe'#调用contact的name方法 - # end end \ No newline at end of file From 20f4b5c44ba469e26035688cf881e4dad9a217ab Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Tue, 27 Jan 2015 15:43:06 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8Acontest=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E7=9A=84=E6=A0=B7=E5=BC=8F=E3=80=8B=20Signed-off-by:?= =?UTF-8?q?=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contests/new_contest.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/contests/new_contest.html.erb b/app/views/contests/new_contest.html.erb index 71c12fad4..0e1b83602 100644 --- a/app/views/contests/new_contest.html.erb +++ b/app/views/contests/new_contest.html.erb @@ -6,7 +6,7 @@ method: :post do |f| %>
<%= render :partial => 'form_contest', :locals => { :f => f } %> - <%= submit_tag l(:button_create) %> + <%= submit_tag l(:button_create), :style=> "margin-left: 100px;margin-top: 10px;" %> <%= javascript_tag "$('#bid_name').focus();" %> <% end %>