From fd5747f4dc558eb9dd27c733c4b433da97e4faf0 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 14 Jul 2014 10:27:54 +0800 Subject: [PATCH 01/10] test 3-framework --- Gemfile | 6 ++- Gemfile.lock | 53 ++++++++++++++++++- Guardfile | 45 ++++++++++++++++ app/models/setting.rb | 2 +- .../test/test_helper.rb | 2 +- test/integration/account_test.rb | 2 +- test/integration/routing/courses_test.rb | 27 ++++++++++ .../scm/adapters/bazaar_adapter_test.rb | 2 +- .../redmine/scm/adapters/cvs_adapter_test.rb | 2 +- .../scm/adapters/darcs_adapter_test.rb | 2 +- .../redmine/scm/adapters/git_adapter_test.rb | 2 +- .../scm/adapters/mercurial_adapter_test.rb | 2 +- .../scm/adapters/subversion_adapter_test.rb | 2 +- 13 files changed, 137 insertions(+), 12 deletions(-) create mode 100644 Guardfile create mode 100644 test/integration/routing/courses_test.rb diff --git a/Gemfile b/Gemfile index 634af9683..4d9e788d8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source 'https://ruby.taobao.org' unless RUBY_PLATFORM =~ /w32/ # unix-like only @@ -19,6 +19,9 @@ gem 'acts-as-taggable-on', '2.4.1' group :development do gem 'better_errors', path: 'lib/better_errors' gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' + gem "guard-rails" + gem 'guard-minitest' + gem 'guard-spork' if ENV['PRY'] gem 'pry' gem 'pry-nav' @@ -26,7 +29,6 @@ group :development do end group :test do - # shoulda的版本做了改动 #gem "shoulda", "~> 3.3.2" gem "shoulda", "> 3.3.2" gem "mocha", "~> 0.13.3" diff --git a/Gemfile.lock b/Gemfile.lock index d30eb7bc4..78b643e44 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,7 +19,7 @@ PATH rails GEM - remote: https://rubygems.org/ + remote: https://ruby.taobao.org/ remote: https://rubygems.org/ specs: actionmailer (3.2.13) @@ -60,6 +60,8 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 1.0.0) + celluloid (0.15.2) + timers (~> 1.1.0) childprocess (0.5.3) ffi (~> 1.0, >= 1.0.11) climate_control (0.0.3) @@ -77,7 +79,24 @@ GEM erubis (2.7.0) execjs (2.0.2) fastercsv (1.5.0) + ffi (1.9.3) ffi (1.9.3-x86-mingw32) + formatador (0.2.5) + guard (2.6.1) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + pry (>= 0.9.12) + thor (>= 0.18.1) + guard-minitest (2.3.1) + guard (~> 2.0) + minitest (>= 3.0) + guard-rails (0.5.2) + guard (~> 2.0) + guard-spork (1.5.1) + childprocess (>= 0.2.3) + guard (>= 1.1) + spork (>= 0.8.4) hike (1.2.3) htmlentities (4.3.2) i18n (0.6.1) @@ -89,16 +108,25 @@ GEM kaminari (0.16.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) + listen (2.7.9) + celluloid (>= 0.15.2) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + lumberjack (1.0.9) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.4) + method_source (0.8.2) mime-types (1.23) + minitest (5.4.0) mocha (0.13.3) metaclass (~> 0.0.1) multi_json (1.7.6) + mysql2 (0.3.11) mysql2 (0.3.11-x86-mingw32) net-ldap (0.3.1) + nokogiri (1.5.11) nokogiri (1.5.11-x86-mingw32) paperclip (3.5.4) activemodel (>= 3.0.0) @@ -106,6 +134,17 @@ GEM cocaine (~> 0.5.3) mime-types polyglot (0.3.3) + pry (0.9.12.6) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + pry (0.9.12.6-x86-mingw32) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + win32console (~> 1.3) + pry-nav (0.2.3) + pry (~> 0.9.10) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) @@ -134,6 +173,9 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (10.3.2) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) + ffi (>= 0.5.0) rdoc (3.12.2) json (~> 1.4) rich (1.4.6) @@ -163,6 +205,8 @@ GEM shoulda-context (1.2.1) shoulda-matchers (2.6.1) activesupport (>= 3.0.0) + slop (3.5.0) + spork (0.9.2) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -170,6 +214,7 @@ GEM tilt (~> 1.1, != 1.3.0) thor (0.18.1) tilt (1.4.1) + timers (1.1.0) treetop (1.4.14) polyglot polyglot (>= 0.3.1) @@ -178,6 +223,7 @@ GEM execjs (>= 0.3.0) json (>= 1.8.0) websocket (1.0.7) + win32console (1.3.2-x86-mingw32) xpath (1.0.0) nokogiri (~> 1.3) @@ -194,6 +240,9 @@ DEPENDENCIES coderay (~> 1.0.6) coffee-rails (~> 3.2.1) fastercsv (~> 1.5.0) + guard-minitest + guard-rails + guard-spork htmlentities i18n (~> 0.6.0) jquery-rails (~> 2.0.2) @@ -203,6 +252,8 @@ DEPENDENCIES net-ldap (~> 0.3.1) nokogiri (< 1.6.0) paperclip (~> 3.5.4) + pry + pry-nav rack-mini-profiler! rack-openid rails (= 3.2.13) diff --git a/Guardfile b/Guardfile new file mode 100644 index 000000000..c30f4195e --- /dev/null +++ b/Guardfile @@ -0,0 +1,45 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +guard 'rails' do + watch('Gemfile.lock') + watch(%r{^(config|lib)/.*}) +end + + +guard :minitest, :drb => true, test_folders: 'test/unit', test_file_patterns: '*_test.rb' do + # with Minitest::Unit + watch(%r{^test/(.*)\/?test_(.*)\.rb$}) + watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" } + watch(%r{^test/test_helper\.rb$}) { 'test' } + + # with Minitest::Spec + # watch(%r{^spec/(.*)_spec\.rb$}) + # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + # watch(%r{^spec/spec_helper\.rb$}) { 'spec' } + + # Rails 4 + # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" } + # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' } + # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" } + # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" } + # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" } + # watch(%r{^test/.+_test\.rb$}) + # watch(%r{^test/test_helper\.rb$}) { 'test' } + + # Rails < 4 + watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" } + watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" } + watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" } +end + +guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do + watch('config/application.rb') + watch('config/environment.rb') + watch('config/environments/test.rb') + watch(%r{^config/initializers/.+\.rb$}) + watch('Gemfile.lock') + watch('spec/spec_helper.rb') { :rspec } + watch('test/test_helper.rb') { :test_unit } + watch(%r{features/support/}) { :cucumber } +end diff --git a/app/models/setting.rb b/app/models/setting.rb index 583d034df..3f11ef7c2 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -163,7 +163,7 @@ class Setting < ActiveRecord::Base end # fixed domain url in development. tantantan's bug - if Rails.env.development? + if Rails.env.development? || Rails.env.test? methods.map do |m| define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/ end diff --git a/lib/plugins/open_id_authentication/test/test_helper.rb b/lib/plugins/open_id_authentication/test/test_helper.rb index 43216e1ef..cb76ceddc 100644 --- a/lib/plugins/open_id_authentication/test/test_helper.rb +++ b/lib/plugins/open_id_authentication/test/test_helper.rb @@ -8,7 +8,7 @@ gem 'actionpack' require 'action_controller' gem 'mocha' -require 'mocha' +require 'mocha/setup' gem 'ruby-openid' require 'openid' diff --git a/test/integration/account_test.rb b/test/integration/account_test.rb index 7562bcf7c..fcb3ce4f8 100644 --- a/test/integration/account_test.rb +++ b/test/integration/account_test.rb @@ -18,7 +18,7 @@ require File.expand_path('../../test_helper', __FILE__) begin - require 'mocha' + require 'mocha/setup' rescue # Won't run some tests end diff --git a/test/integration/routing/courses_test.rb b/test/integration/routing/courses_test.rb new file mode 100644 index 000000000..5554cb03d --- /dev/null +++ b/test/integration/routing/courses_test.rb @@ -0,0 +1,27 @@ +# Redmine - project management software +# Copyright (C) 2006-2013 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require File.expand_path('../../../test_helper', __FILE__) + +class RoutingProjectsTest < ActionController::IntegrationTest + def test_courses + assert_routing( + { :method => 'get', :path => "/courses" }, + { :controller => 'projects', :action => 'index' } + ) + end +end diff --git a/test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb index d69da033f..3e3f6ca88 100644 --- a/test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../../../../../test_helper', __FILE__) begin - require 'mocha' + require 'mocha/setup' class BazaarAdapterTest < ActiveSupport::TestCase REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s diff --git a/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb index 6b2a804e0..cddedf871 100644 --- a/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../../../../../test_helper', __FILE__) begin - require 'mocha' + require 'mocha/setup' class CvsAdapterTest < ActiveSupport::TestCase REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s diff --git a/test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb index 5b689001a..f5a642689 100644 --- a/test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../../../../../test_helper', __FILE__) begin - require 'mocha' + require 'mocha/setup' class DarcsAdapterTest < ActiveSupport::TestCase REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s diff --git a/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb index 946ea4bfa..443b900bf 100644 --- a/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../../../../../test_helper', __FILE__) begin - require 'mocha' + require 'mocha/setup' class GitAdapterTest < ActiveSupport::TestCase REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s diff --git a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb index c23e7debd..ee31ff030 100644 --- a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../../../../../test_helper', __FILE__) begin - require 'mocha' + require 'mocha/setup' class MercurialAdapterTest < ActiveSupport::TestCase HELPERS_DIR = Redmine::Scm::Adapters::MercurialAdapter::HELPERS_DIR diff --git a/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb index 8bf08f011..dba1a6d43 100644 --- a/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb @@ -18,7 +18,7 @@ require File.expand_path('../../../../../../test_helper', __FILE__) begin - require 'mocha' + require 'mocha/setup' class SubversionAdapterTest < ActiveSupport::TestCase From 3aab1b172c88beba760d149f6ba3fceeb4d9f5b2 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 14 Jul 2014 11:28:29 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB=E6=97=B6=E7=9A=84=E2=80=98?= =?UTF-8?q?page=5Ftype=3D=E2=80=99=20undefine=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20140710071720_create_first_pages.rb | 3 +++ db/migrate/20140710095123_add_cloumn_to_first_page.rb | 8 ++++---- db/migrate/20140711010124_alt_column_name.rb | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/db/migrate/20140710071720_create_first_pages.rb b/db/migrate/20140710071720_create_first_pages.rb index fa7d01601..c33283a06 100644 --- a/db/migrate/20140710071720_create_first_pages.rb +++ b/db/migrate/20140710071720_create_first_pages.rb @@ -5,6 +5,7 @@ class CreateFirstPages < ActiveRecord::Migration t.string :web_title t.string :title t.string :description + t.string :page_type t.timestamps end @@ -12,6 +13,8 @@ class CreateFirstPages < ActiveRecord::Migration fp.web_title = "Trustie - 为大学生技术创新筑巢" fp.title = "Trustie在线项目托管平台" fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" + fp.page_type = "project" + fp.save end end diff --git a/db/migrate/20140710095123_add_cloumn_to_first_page.rb b/db/migrate/20140710095123_add_cloumn_to_first_page.rb index 6720a8aa4..8642f08a2 100644 --- a/db/migrate/20140710095123_add_cloumn_to_first_page.rb +++ b/db/migrate/20140710095123_add_cloumn_to_first_page.rb @@ -1,9 +1,9 @@ class AddCloumnToFirstPage < ActiveRecord::Migration def change - add_column :first_pages,:type,:string + #add_column :first_pages,:type,:string - fr = FirstPage.all.first - fr.type = "project" - fr.save + #fr = FirstPage.all.first + #fr.type = "project" + #fr.save end end diff --git a/db/migrate/20140711010124_alt_column_name.rb b/db/migrate/20140711010124_alt_column_name.rb index 24b784765..50a531d54 100644 --- a/db/migrate/20140711010124_alt_column_name.rb +++ b/db/migrate/20140711010124_alt_column_name.rb @@ -1,5 +1,5 @@ class AltColumnName < ActiveRecord::Migration def change - rename_column :first_pages,:type,:page_type + #rename_column :first_pages,:type,:page_type end end From 2a1a0513624a35a53263d22b63b198f7ccc00003 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 14 Jul 2014 15:15:28 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=AF=86=E7=BA=A7BUG=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 113 ++++++++++-------- .../_course_show_all_attachment.html.erb | 2 +- .../_course_sort_by_attachtypel.html.erb | 2 +- db/schema.rb | 3 +- 4 files changed, 69 insertions(+), 51 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index b86630d98..a89f224b6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -92,57 +92,74 @@ class RepositoriesController < ApplicationController end def create - ##xianbo - @root_path=RepositoriesHelper::ROOT_PATH - @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" - @project_path=@root_path+"htdocs/"+@repository_name - @repository_tag=params[:repository][:upassword] - @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] - logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag - logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name - attrs = pickup_extra_info - if((@repository_tag!="")&¶ms[:repository_scm]=="Git") + if params[:repository_scm].to_s == 'Gitlab' + # add by nwb + # 增加对gitlab版本库的支持 + attrs = pickup_extra_info + @repository = Repository.factory(params[:repository_scm]) + @repository.safe_attributes = params[:repository] + if attrs[:attrs_extra].keys.any? + @repository.merge_extra_info(attrs[:attrs_extra]) + end + @repository.project = @project + if request.post? && @repository.save + redirect_to settings_project_path(@project, :tab => 'repositories') + else + render :action => 'new' + end + else # 原逻辑 + ##xianbo + @root_path=RepositoriesHelper::ROOT_PATH + @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" + @project_path=@root_path+"htdocs/"+@repository_name + @repository_tag=params[:repository][:upassword] + @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] + logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag + logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name + attrs = pickup_extra_info + if((@repository_tag!="")&¶ms[:repository_scm]=="Git") params[:repository][:url]=@project_path - end - ###xianbo - @repository = Repository.factory(params[:repository_scm]) - @repository.safe_attributes = params[:repository] - if attrs[:attrs_extra].keys.any? - @repository.merge_extra_info(attrs[:attrs_extra]) - end - #by xianbo - - @repository.project = @project - if request.post? && @repository.save - if(params[:repository_scm]=="Git") - system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag - system "echo -e '"+@repo_name+"-write:"+ - " "+@repo_name+"' >> "+@root_path+"group.passwd" - system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s - system "git init --bare "+@project_path - system "mv "+@project_path+"/hooks/post-update{.sample,}" - system "chmod a+x "+@project_path+"/hooks/post-update" - system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - " \n"+ - "Require group "+@repo_name+"-write \n "+ - " \n ' >> "+ - @root_path+"htdocs/"+ @repository_name+"/.htaccess" - system "cd "+@project_path+" ;git update-server-info" - # if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info) - # else - # logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+ - # crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+ - # "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info - # end + end + ###xianbo + @repository = Repository.factory(params[:repository_scm]) + @repository.safe_attributes = params[:repository] + if attrs[:attrs_extra].keys.any? + @repository.merge_extra_info(attrs[:attrs_extra]) + end + #by xianbo + + @repository.project = @project + if request.post? && @repository.save + if(params[:repository_scm]=="Git") + system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag + system "echo -e '"+@repo_name+"-write:"+ + " "+@repo_name+"' >> "+@root_path+"group.passwd" + system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s + system "git init --bare "+@project_path + system "mv "+@project_path+"/hooks/post-update{.sample,}" + system "chmod a+x "+@project_path+"/hooks/post-update" + system "echo -e 'Allow from all \n Order Deny,Allow \n "+ + " \n"+ + "Require group "+@repo_name+"-write \n "+ + " \n ' >> "+ + @root_path+"htdocs/"+ @repository_name+"/.htaccess" + system "cd "+@project_path+" ;git update-server-info" + # if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info) + # else + # logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+ + # crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+ + # "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info + # end @repository.update_attributes(:login => User.current.login.to_s) - end - redirect_to settings_project_path(@project, :tab => 'repositories') - else if(@repository_tag) - render :action => 'newrepo', :layout =>'base_projects' - else - render :action => 'new', :layout =>'base_projects' + end + redirect_to settings_project_path(@project, :tab => 'repositories') + else if(@repository_tag) + render :action => 'newrepo', :layout =>'base_projects' + else + render :action => 'new', :layout =>'base_projects' + end + end end - end end def edit diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb index a6da426c6..f94ddc20b 100644 --- a/app/views/files/_course_show_all_attachment.html.erb +++ b/app/views/files/_course_show_all_attachment.html.erb @@ -35,7 +35,7 @@ <% end -%> <% container.attachments.each do |file| %> - <%if file.is_public == 0 && !User.current.member_of?(@project)%> + <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> <%next%> <%end%> "> diff --git a/app/views/files/_course_sort_by_attachtypel.html.erb b/app/views/files/_course_sort_by_attachtypel.html.erb index cda832493..f0f6c8270 100644 --- a/app/views/files/_course_sort_by_attachtypel.html.erb +++ b/app/views/files/_course_sort_by_attachtypel.html.erb @@ -28,7 +28,7 @@ <% @containers.each do |container| %> <% next if container.attachments.empty? -%> <% container.attachments.each do |file| %> - <% if file.is_public == 0 && !User.current.member_of?(@project) %> + <% if file.is_public == 0 && !User.current.member_of_course?(@course) %> <% next %> <% end %> <% if isTypeOk(file, selAttachType, selContentType) %> diff --git a/db/schema.rb b/db/schema.rb index fa41ed1d5..a304bf94f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140711012924) do +ActiveRecord::Schema.define(:version => 20140714021812) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -379,6 +379,7 @@ ActiveRecord::Schema.define(:version => 20140711012924) do t.text "description" t.datetime "created_on" t.integer "user_id", :default => 0 + t.integer "is_public", :default => 1 end add_index "documents", ["category_id"], :name => "index_documents_on_category_id" From 14f1ad63d220735bafe08d23e503a97803bf1140 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 14 Jul 2014 16:11:38 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 17 ++++--- Gemfile.lock | 61 +++++++++++++++--------- Guardfile | 60 +++++++++++------------ doc/Automated testing documentation.doc | Bin 0 -> 16896 bytes test/test_helper.rb | 52 ++++++++++++++++++++ 5 files changed, 128 insertions(+), 62 deletions(-) create mode 100644 doc/Automated testing documentation.doc diff --git a/Gemfile b/Gemfile index 4d9e788d8..0965c955a 100644 --- a/Gemfile +++ b/Gemfile @@ -19,13 +19,6 @@ gem 'acts-as-taggable-on', '2.4.1' group :development do gem 'better_errors', path: 'lib/better_errors' gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' - gem "guard-rails" - gem 'guard-minitest' - gem 'guard-spork' - if ENV['PRY'] - gem 'pry' - gem 'pry-nav' - end end group :test do @@ -36,6 +29,16 @@ group :test do gem 'nokogiri', '< 1.6.0' end +group :development, :test do + gem "guard-rails" + gem 'spork-testunit' + gem 'guard-spork' + gem 'guard-test', '~> 1.0.0' + gem 'ruby-prof' + gem 'pry' + gem 'pry-nav' +end + # Gems used only for assets and not required # in production environments by default. diff --git a/Gemfile.lock b/Gemfile.lock index 78b643e44..fe06a5e46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,7 +51,7 @@ GEM multi_json (~> 1.0) acts-as-taggable-on (2.4.1) rails (>= 3, < 5) - arel (3.0.2) + arel (3.0.3) builder (3.0.0) capybara (2.0.3) mime-types (>= 1.16) @@ -72,13 +72,13 @@ GEM coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) - coffee-script (2.2.0) + coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.7.0) + coffee-script-source (1.7.1) erubis (2.7.0) - execjs (2.0.2) - fastercsv (1.5.0) + execjs (2.2.1) + fastercsv (1.5.5) ffi (1.9.3) ffi (1.9.3-x86-mingw32) formatador (0.2.5) @@ -88,26 +88,28 @@ GEM lumberjack (~> 1.0) pry (>= 0.9.12) thor (>= 0.18.1) - guard-minitest (2.3.1) - guard (~> 2.0) - minitest (>= 3.0) guard-rails (0.5.2) guard (~> 2.0) guard-spork (1.5.1) childprocess (>= 0.2.3) guard (>= 1.1) spork (>= 0.8.4) + guard-test (1.0.0) + guard (>= 1.8) + test-unit (~> 2.2) hike (1.2.3) htmlentities (4.3.2) i18n (0.6.1) + iconv (1.0.4) journey (1.0.4) jquery-rails (2.0.3) railties (>= 3.1.0, < 5.0) thor (~> 0.14) - json (1.8.0) + json (1.8.1) kaminari (0.16.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) + libv8 (3.16.14.3) listen (2.7.9) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) @@ -118,11 +120,10 @@ GEM treetop (~> 1.4.8) metaclass (0.0.4) method_source (0.8.2) - mime-types (1.23) - minitest (5.4.0) + mime-types (1.25.1) mocha (0.13.3) metaclass (~> 0.0.1) - multi_json (1.7.6) + multi_json (1.10.1) mysql2 (0.3.11) mysql2 (0.3.11-x86-mingw32) net-ldap (0.3.1) @@ -133,7 +134,7 @@ GEM activesupport (>= 3.0.0) cocaine (~> 0.5.3) mime-types - polyglot (0.3.3) + polyglot (0.3.5) pry (0.9.12.6) coderay (~> 1.0) method_source (~> 0.8) @@ -148,12 +149,12 @@ GEM rack (1.4.5) rack-cache (1.2) rack (>= 0.4) - rack-openid (1.3.1) + rack-openid (1.4.2) rack (>= 1.1.0) ruby-openid (>= 2.1.8) rack-raw-upload (1.1.1) multi_json - rack-ssl (1.3.3) + rack-ssl (1.3.4) rack rack-test (0.6.2) rack (>= 1.0) @@ -178,6 +179,7 @@ GEM ffi (>= 0.5.0) rdoc (3.12.2) json (~> 1.4) + ref (1.0.5) rich (1.4.6) jquery-rails kaminari @@ -188,8 +190,9 @@ GEM sass-rails rmagick (2.13.2) ruby-openid (2.1.8) - rubyzip (1.1.4) - sass (3.2.14) + ruby-prof (0.15.1) + rubyzip (1.1.6) + sass (3.3.10) sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) @@ -207,27 +210,36 @@ GEM activesupport (>= 3.0.0) slop (3.5.0) spork (0.9.2) + spork-testunit (0.0.8) + spork (>= 0.6.0) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - thor (0.18.1) + test-unit (2.5.5) + therubyracer (0.12.1) + libv8 (~> 3.16.14.0) + ref + thor (0.19.1) tilt (1.4.1) timers (1.1.0) - treetop (1.4.14) + treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.37) - uglifier (2.4.0) + tzinfo (0.3.40) + uglifier (2.5.1) execjs (>= 0.3.0) json (>= 1.8.0) websocket (1.0.7) win32console (1.3.2-x86-mingw32) xpath (1.0.0) nokogiri (~> 1.3) + zip-zip (0.3) + rubyzip (>= 1.0.0) PLATFORMS + ruby x86-mingw32 DEPENDENCIES @@ -240,11 +252,12 @@ DEPENDENCIES coderay (~> 1.0.6) coffee-rails (~> 3.2.1) fastercsv (~> 1.5.0) - guard-minitest guard-rails guard-spork + guard-test (~> 1.0.0) htmlentities i18n (~> 0.6.0) + iconv jquery-rails (~> 2.0.2) kaminari mocha (~> 0.13.3) @@ -260,8 +273,12 @@ DEPENDENCIES rich (= 1.4.6) rmagick (>= 2.0.0) ruby-openid (~> 2.1.4) + ruby-prof + rubyzip sass-rails (~> 3.2.3) seems_rateable! shoulda (> 3.3.2) + spork-testunit therubyracer uglifier (>= 1.0.3) + zip-zip diff --git a/Guardfile b/Guardfile index c30f4195e..75aa93c15 100644 --- a/Guardfile +++ b/Guardfile @@ -1,45 +1,39 @@ -# A sample Guardfile # More info at https://github.com/guard/guard#readme -guard 'rails' do +# guard 'rails' do +# watch('Gemfile.lock') +# watch(%r{^(config|lib)/.*}) +# end +# +guard 'spork', :test_unit => true, :test_unit_env => {'RAILS_ENV' => 'test'}, :wait => 60 do + watch('config/application.rb') + watch('config/environment.rb') + watch('config/environments/test.rb') + watch(%r{^config/initializers/.+\.rb$}) watch('Gemfile.lock') - watch(%r{^(config|lib)/.*}) + watch('spec/spec_helper.rb') { :rspec } + watch('test/test_helper.rb') { :test_unit } + watch(%r{features/support/}) { :cucumber } end +guard :test, :drb => true, :all_after_pass => false, :all_on_start => false do + watch(%r{^test/.+_test\.rb$}) + watch('test/test_helper.rb') { 'test' } -guard :minitest, :drb => true, test_folders: 'test/unit', test_file_patterns: '*_test.rb' do - # with Minitest::Unit - watch(%r{^test/(.*)\/?test_(.*)\.rb$}) - watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" } - watch(%r{^test/test_helper\.rb$}) { 'test' } - - # with Minitest::Spec - # watch(%r{^spec/(.*)_spec\.rb$}) - # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - # watch(%r{^spec/spec_helper\.rb$}) { 'spec' } + # Non-rails + watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" } # Rails 4 - # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" } - # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' } - # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" } + # watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" } + # watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' } + # watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" } # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" } - # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" } - # watch(%r{^test/.+_test\.rb$}) - # watch(%r{^test/test_helper\.rb$}) { 'test' } + # watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" } # Rails < 4 - watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" } - watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" } - watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" } -end - -guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do - watch('config/application.rb') - watch('config/environment.rb') - watch('config/environments/test.rb') - watch(%r{^config/initializers/.+\.rb$}) - watch('Gemfile.lock') - watch('spec/spec_helper.rb') { :rspec } - watch('test/test_helper.rb') { :test_unit } - watch(%r{features/support/}) { :cucumber } + watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" } + watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" } + watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" } + watch(%r{^app/views/.+$}) { 'test/integration' } + watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] } end diff --git a/doc/Automated testing documentation.doc b/doc/Automated testing documentation.doc new file mode 100644 index 0000000000000000000000000000000000000000..d015061817d10aeffdeb5a14763d012070b076a6 GIT binary patch literal 16896 zcmeHO4Rln+6`r@*Y<5EuB9TB5WsPZ)MiY_{AfZ-6K*S)MWEV_1Kz?`gQ^*E3$%52s z#4Vty5-ckHv)HP&tyTKxQR}JJo};Z5!E=^28;(_0^&Si0+0cm4@?9yfl0t* z;1j?U-~wPOa3R2YriJg}=ErVlNds=tgydTB<=QD)!-w9j{WC51|*}x}(93U6S13m@h1D67q z0R=!IFdZlYih&Yf22cvj1ZDxVfij>Rm;-zoxE%Nlz`kCIdj&8Ts05fdANQ-m@rXwM zw__T5o&X2WUfLXdq6_hiyov?%--|n10$tr*tv$}Vu7I~-e%GqrPM^O=J`)yum^Z(x zMLr1_FGNC?7nX@5}7RFx?j7HU>lla^j=skG3ltRks>#}22o#tcYPkt33G#JB~TdBZbvUX@eK zv};Yct*~pA!Xmk8dnPySI0LG=p2-@MN7=HC4>AYqEl=Vx?U}9hZxQQzYO# z$iUjIBFB=PV=?NGHz~nXLxQP>1lCg|;0(%uJQXRlKHz~nnLxRba0E9zAmN+@>u>PL(2o6z)Um3=)7o%4!Hpux-Z$TPO z%L4DIH1r21&3Q3ssArSr;utj4qe)X7gNE8NY39bDp*BpK+88wSS0+tU3>x|~lV)uU z8u~kWKkDaZjkQMWrzEVyj6nm3IhnQ{=Gzv7k9r-6@4gs(hE1CjN^Q>=#~%*U7s{#X z{}(Z6RQd)-Sd!Kzy9IMy|Ph@K1i>ldG_k+aGA*ld&@2v8G*!J`9yEx`8Y5F;u$f z0UChI(TXMv?_-hPhtK9qM8^Gx#QFEH7q)B->+k9+8=RU=dXJi_BvD^whXb3+`qRnn zgcKIhvTC!BtNd(mV-*i>uGOcf&$YN^FDzn`yL}5OKMCJZU*&+UWP!igLd{vkjvWW! zT2t}d&Hyj@Q_%VZv?@IY8JZA<({f6w1L1ZL2A4K)$B`@PjhYRLjgrDD+P7TZ{>9oS zmXj(^Qt|1}p5JNVDj-2jY{=`S^qE*G)Q4tURsxM7*sAQw1@JK?;tJ`bXo-npiRgfy zS3}#}-{j+2pfzP{^v>CaXUe8$Dil?c$7sXmrgta(r3$_D$5bZzbs1#3+48J~D-=U& zgJT@lEJh2|h>b0T{oa!aq?C?MK6|;@3Sd)(o4jmCF(JBz6AxRT zScf~egn>*0EDGgOdxb89DK_J{QifBfL24Kua1|XrqK{!O;v! z1K{gHybE$Vg-7Oeh*ofq)~DIo@kuvNO2*bGCAJ^d0d3PL(y_Q-x_b|Fpqaxn0#~g5 zQ2*WFQ*|`chB`;6%PiXL`}OLZzWPW*_YE)KD}*ObuKDO^7kcWI`ZU^iiuurNP+CKi zXv5vmg$Fu}N0QU2vl32Gv)?{hi2G4>yR3fF!#U5-$jbc=duFuv0&dsC+AVVHXBD>$ z(78wF8jCz3)`5;rH9T8b$yhi84NNFH1Ex_}hI$qG@Ee5(#iuPvpHio;PY9>du)XNO z4D-U`*I}NGb1mw8wg1uXTRvOhJyvfJrDE=R;nhgj0U92V(dTeWIZ~O@;KB%-dH85`d;0gcVdatgx35p z^1KG{9QQ4NYlcGr*A4#!SkGTi80Y&uqpj=kd%Mt|lzje!> z2Y#^sXHTM7z6VIdeXh5&!{5=}6KLw`3WW1nx2r4A*|fUQ+tt%KA}!nH8BGNs`g)(9 z4S{8xX@m-1ZkwNwfBPPd@xH$;ot$;g9(G@bSo&kVmREPb`t`yK(!YEU^mp0ON9H3h zaY)_@wHj# zSr5;l(9EO(ah-{kaZ}go zCV!ccYfyx*R(qx>$%Xv?r*tUlGdksAI=+Vh7m z8aDS=pr@t2f;%n443i+%;~ctwGaNzJ&ZL?>n4-;KEXMTO02wThXX3vp%l|X`WVl4m zz*jIHoatvfyaPG#HyGYWf_C_E2a9<9<8E@Sy)g}pY2cjFz}q)J&~zE(ZQ^;~VL;8LAScFJ}9hCkfMxFL}r z?+w<=Hg|hhRI@Az%l0*p%#WjjrNC8?uox%Jl+lT!xJs1w;K$R!EaXrUH)?6d!G=?? z-TOXo>tU~xu>9u%gdf{tCuA>_JuN~H%4I*=pamcDo6*Bkw7{AIgEbX^OHETl<-iO` zHxu-;QD&}GQ5H~Sh#q6w%7XUC+HwSSl?sjWaH$7v zvSyyYa^wpkH$mOBp@hc@-f#)+rC649Lnqv9twM@=rk)HrO??)Cf`=BZVTxi|ufd%v zYVQ8(@}{=;U9=Ae+A(^ctF%}!C|@p4Yn?cazENC(JNv{Ii;$Blg0=fx#_Vv2Ij&7E zTIYUOUqdM97gLt8$0@pXNxsWyArz#woEZ4+)@!$HlH1A@{a|ph`}M8UTR#jQT~2O; z#!?ilEpT;0{ua>=9fX1jU&`xE(TjUI(rclY4)l&Ak&AINsd7cRZ;s2bhFCPyp>w`d z=!Jf8!mbBvmsO{_);8>3Vkx37j@8}anl|uYeTtrWleRuZ-|u?CV_mZQ`m2{+y)3^m zzcCav=3c}@{Dj;p}+1K*p~A9!pl zB9$*MfdhGh{ zZM%Fs-Cx+s*5n}q>^;(k1NOJ5`60L2_vl&X!>sk8H>|x0w$AZ3XN^#nvGBj3 z0erh+#kVXt=NUJz>LTM+Cw9d)Zbi=ra)3Ob6qpbAfi=L5z;@u6s)T>2iNC9fgKFYH z%)~uv$+nmYwcxD9ZFwRyTf3%JqXad0)10kMGSl{bMLgpvPY*g-s^NWz38op$w0U>z z!x&)B?c-S$->MpKR>QG1!)KT7v!SAd*+NDvX2fbn?1&_kiq=xTt{s#%G4lBlg-5%_ zyJ#im;Mm>`JOjK4>;wJ?yagNt_zwCJFb{@@2V;oHcQR(ieP)FBs06eY2~j0ci3p7n zJNGrN*vAl!k1RVoX&T<<9rA>38dpC(F7m|;5R2@<8M0X)9}BFHyGta16u0VB&z zSxq@jxz)UnL2i-6G2RJ03_K1z3A_aGTeGOKkMiYFi824LDeJHQviZ+({yp#p@D7lN zJzxp&A>hYrsWrd`;5Og|APsxN)j$y7w}??T@~~>g-%}G&1{384qE>+4RC&IkChk@f z+ttLKYGOc5+@U6JRTG=lgc{efMWPiS?HeDxBPCSW1{c&x_?%NIQRX~-kco4D{*UJv zz68ukgWm@RfX9G~u>a2j_zeI)g@}aXktk0Hln`}Pa9AmjADRrN4-UoBDGRt{U}s`BP*P(N#RFwp(HcrM1Gb!3BGQUJ z0ujfmICnI_4}CwX|No@h8~Q(F!}XNkRP}{F^VP&WwBLz$6xBFY{@ifnBj!!O`3t|Y z;h_q@ksgs)DKuNs(5~^{07~I$M3d1v+hw2PZJ+Y;^oOAspDH(@=VvNITDX0-&0y3z z@|CiFA3mNT5${3y|5bd`!T-Ycw literal 0 HcmV?d00001 diff --git a/test/test_helper.rb b/test/test_helper.rb index 8d0666854..9b1a4f158 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,55 @@ +require 'rubygems' +require 'spork' +#uncomment the following line to use spork with the debugger +#require 'spork/ext/ruby-debug' + +Spork.prefork do + # Loading more in this block will cause your tests to run faster. However, + # if you change any configuration or code from libraries loaded here, you'll + # need to restart spork for it take effect. + ENV["RAILS_ENV"] = "test" + require File.expand_path('../../config/environment', __FILE__) + require 'rails/test_help' + +end + +Spork.each_run do + # This code will be run each time you run your specs. + +end + +# --- Instructions --- +# Sort the contents of this file into a Spork.prefork and a Spork.each_run +# block. +# +# The Spork.prefork block is run only once when the spork server is started. +# You typically want to place most of your (slow) initializer code in here, in +# particular, require'ing any 3rd-party gems that you don't normally modify +# during development. +# +# The Spork.each_run block is run each time you run your specs. In case you +# need to load files that tend to change during development, require them here. +# With Rails, your application modules are loaded automatically, so sometimes +# this block can remain empty. +# +# Note: You can modify files loaded *from* the Spork.each_run block without +# restarting the spork server. However, this file itself will not be reloaded, +# so if you change any of the code inside the each_run block, you still need to +# restart the server. In general, if you have non-trivial code in this file, +# it's advisable to move it into a separate file so you can easily edit it +# without restarting spork. (For example, with RSpec, you could move +# non-trivial code into a file spec/support/my_helper.rb, making sure that the +# spec/support/* files are require'd from inside the each_run block.) +# +# Any code that is left outside the two blocks will be run during preforking +# *and* during each_run -- that's probably not what you want. +# +# These instructions should self-destruct in 10 seconds. If they don't, feel +# free to delete them. + + + + # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # From cf339edb6caec186d132195433e3db24baba5e89 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 14 Jul 2014 16:12:58 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=AE=9A=E5=88=B6=E7=9A=84=E9=9D=9E=E7=A9=BA=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=EF=BC=8C=E9=95=BF=E5=BA=A6=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 14 ++-- app/models/first_page.rb | 3 + config/locales/zh.yml | 2 + db/migrate/20140714081030_set_web_title.rb | 8 +++ db/schema.rb | 74 ++++------------------ 5 files changed, 34 insertions(+), 67 deletions(-) create mode 100644 db/migrate/20140714081030_set_web_title.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index d87644e43..fea29759d 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -246,19 +246,21 @@ class AdminController < ApplicationController @first_page.title = params[:title] if @first_page.save respond_to do |format| + flash[:notice] = l(:notice_successful_update) format.html { - flash[:notice] = l(:notice_successful_update) redirect_to admin_first_page_made_path } format.api { render_api_ok } + #format.json { render json: @first_page, status: :created, location: @first_page } end else respond_to do |format| + flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}" format.html { - first_page_made render :action => 'first_page_made' } format.api { render_validation_errors(@first_page) } + #format.json { render json: @first_page.errors, status: :unprocessable_entity } end end end @@ -272,6 +274,7 @@ class AdminController < ApplicationController @first_page = FirstPage.where("page_type = 'project'").first @course_page = FirstPage.where("page_type = 'course'").first @first_page.web_title = params[:web_title] + @course_page.web_title = params[:web_title] @course_page.title = params[:course_title] @course_page.description = params[:course_description] if @first_page.save && @course_page.save @@ -284,8 +287,10 @@ class AdminController < ApplicationController end else respond_to do |format| + flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@course_page.errors.full_messages[0]}" + #flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}" format.html { - course_page_made + render :action => 'course_page_made' } format.api { render_validation_errors(@first_page) } @@ -303,6 +308,7 @@ class AdminController < ApplicationController @first_page = FirstPage.where("page_type = 'project'").first @contest_page = FirstPage.where("page_type = 'contest'").first @first_page.web_title = params[:web_title] + @contest_page.web_title = params[:web_title] @contest_page.title = params[:contest_title] @contest_page.description = params[:contest_description] if @first_page.save && @contest_page.save @@ -315,8 +321,8 @@ class AdminController < ApplicationController end else respond_to do |format| + flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@contest_page.errors.full_messages[0]}" format.html { - contest_page_made render :action => 'contest_page_made' } format.api { render_validation_errors(@first_page) } diff --git a/app/models/first_page.rb b/app/models/first_page.rb index b284c8fdc..113edc0f8 100644 --- a/app/models/first_page.rb +++ b/app/models/first_page.rb @@ -1,3 +1,6 @@ class FirstPage < ActiveRecord::Base attr_accessible :description, :title, :web_title,:page_type + validates_presence_of :web_title, :title, :description,:page_type + validates_length_of :web_title,:title, maximum: 30 + validates_length_of :description, maximum: 100 end diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d3377fca9..f24ef0ae5 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -266,6 +266,7 @@ zh: field_value: 值 field_category: 类别 field_title: 标题 + field_web_title: 浏览器标题 field_project: 项目 field_issue: 问题 field_status: 状态 @@ -1909,6 +1910,7 @@ zh: label_memo_create_fail: 发布失败 label_forum_create_succ: 贴吧新建成功 label_forum_create_fail: 贴吧新建失败 + label_first_page_create_fail: 首页定制失败 label_forum_edit: 编辑讨论区 label_memo_create: 发布 label_memo_new: 新建主题 diff --git a/db/migrate/20140714081030_set_web_title.rb b/db/migrate/20140714081030_set_web_title.rb new file mode 100644 index 000000000..48921ed4e --- /dev/null +++ b/db/migrate/20140714081030_set_web_title.rb @@ -0,0 +1,8 @@ +class SetWebTitle < ActiveRecord::Migration + def change + FirstPage.all.each do |fp| + fp.web_title = "Trustie - 为大学生技术创新筑巢" + fp.save + end + end +end diff --git a/db/schema.rb b/db/schema.rb index fa41ed1d5..0e170a64f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -177,58 +177,6 @@ ActiveRecord::Schema.define(:version => 20140711012924) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -411,9 +359,9 @@ ActiveRecord::Schema.define(:version => 20140711012924) do t.string "web_title" t.string "title" t.string "description" + t.string "page_type" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "page_type" end create_table "forums", :force => true do |t| @@ -806,18 +754,18 @@ ActiveRecord::Schema.define(:version => 20140711012924) do create_table "relative_memos", :force => true do |t| t.integer "osp_id" t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false t.integer "author_id" - t.integer "replies_count", :default => 0 + t.integer "replies_count", :default => 0 t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 t.string "url" t.string "username" t.string "userhomeurl" From e6b80de3b5954d3bbf0e90ecfa25d4b6f3d0a372 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 14 Jul 2014 16:51:18 +0800 Subject: [PATCH 06/10] =?UTF-8?q?rmagick=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=E4=BB=85test=E9=9C=80=E8=A6=81=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 634af9683..5e67af6e7 100644 --- a/Gemfile +++ b/Gemfile @@ -32,6 +32,15 @@ group :test do gem "mocha", "~> 0.13.3" gem 'capybara', '~> 2.0.0' gem 'nokogiri', '< 1.6.0' + + platforms :mri, :mingw do + group :rmagick do + # RMagick 2 supports ruby 1.9 + # RMagick 1 would be fine for ruby 1.8 but Bundler does not support + # different requirements for the same gem on different platforms + gem "rmagick", ">= 2.0.0" + end + end end @@ -53,15 +62,6 @@ group :ldap do end -platforms :mri, :mingw do - group :rmagick do - # RMagick 2 supports ruby 1.9 - # RMagick 1 would be fine for ruby 1.8 but Bundler does not support - # different requirements for the same gem on different platforms - gem "rmagick", ">= 2.0.0" - end -end - # Optional gem for OpenID authentication group :openid do gem "ruby-openid", "~> 2.1.4", :require => "openid" From 37d0560b70da5acacb67f7cf9f25491b0eb23a9c Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 15 Jul 2014 10:27:24 +0800 Subject: [PATCH 07/10] test test --- config/routes.rb | 1 - test/integration/routing/courses_test.rb | 71 +++++++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index dfb8d503b..b6e2d7ff3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -577,7 +577,6 @@ RedmineApp::Application.routes.draw do end end - match 'projects/course', :to => 'courses#course', :as => 'courses_course' match 'courses/search', :to => 'courses#search' # add by nwb # 课程路由设置 diff --git a/test/integration/routing/courses_test.rb b/test/integration/routing/courses_test.rb index 5554cb03d..ee9a8bd0d 100644 --- a/test/integration/routing/courses_test.rb +++ b/test/integration/routing/courses_test.rb @@ -21,7 +21,76 @@ class RoutingProjectsTest < ActionController::IntegrationTest def test_courses assert_routing( { :method => 'get', :path => "/courses" }, - { :controller => 'projects', :action => 'index' } + { :controller => 'courses', :action => 'index' } ) end + def test_courses_search + assert_routing( + "/courses/search", + {controller: 'courses', action: 'search'} + ) + end + + def test_courses_item + assert_routing( + 'courses/233', + {controller: 'courses', action: 'show', id: '233'} + ) + # id eq str + assert_routing( + 'courses/timestypo', + {controller: 'courses', action: 'show', id: 'timestypo'} + ) + end + + def test_course_setting + assert_routing( + 'courses/233/settings', + {controller: 'courses', action: 'settings', id: '233'} + ) + end + + def test_course_homework + assert_routing( + 'courses/233/homework', + {controller: 'courses', action: 'homework', id: '233'} + ) + assert_routing( + 'courses/233/new_homework', + {controller: 'courses', action: 'new_homework', id: '233'} + ) + end + + def test_course_file + assert_routing( + 'courses/233/file', + {controller: 'courses', action: 'file', id: '233'} + ) + end + + def test_course_feedback + assert_routing( + 'courses/233/feedback', + {controller: 'courses', action: 'feedback', id: '233'} + ) + end + + def test_course_member + assert_routing( + 'courses/233/member', + {controller: 'courses', action: 'member', id: '233'} + ) + end + + def test_course_finish_restart_course + assert_routing( + {path: 'courses/233/finishcourse', method: :post}, + {controller: 'courses', action: 'finishcourse', id: '233'} + ) + assert_routing( + {path: 'courses/233/restartcourse', method: :post}, + {controller: 'courses', action: 'restartcourse', id: '233'} + ) + end + end From 6a45a0287d46a20f025a8e9255f36d6000357d83 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 15 Jul 2014 16:13:50 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99=E7=95=8C?= =?UTF-8?q?=E9=9D=A2form.quene=20undefine=E7=9A=84js=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=88=E5=AF=BC=E8=87=B4=E5=8A=A0=E8=BD=BD=E4=B8=AD=E4=B8=8D?= =?UTF-8?q?=E6=B6=88=E5=A4=B1=E7=9A=84=E5=8E=9F=E5=9B=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/avatar_controller.rb | 36 +++++++++- app/helpers/avatar_helper.rb | 2 +- app/views/admin/contest_page_made.html.erb | 2 +- app/views/admin/course_page_made.html.erb | 2 +- app/views/admin/first_page_made.html.erb | 2 +- app/views/avatar/_avatar_form.html.erb | 5 +- app/views/avatar/delete_image.js.erb | 5 ++ app/views/my/account.html.erb | 21 +++--- config/locales/zh.yml | 1 + config/routes.rb | 1 + db/migrate/20140714081030_set_web_title.rb | 1 + db/schema.rb | 76 ++++++++++++++++++---- public/javascripts/application.js | 2 +- public/javascripts/avatars.js | 1 + 14 files changed, 128 insertions(+), 29 deletions(-) create mode 100644 app/views/avatar/delete_image.js.erb diff --git a/app/controllers/avatar_controller.rb b/app/controllers/avatar_controller.rb index 73c1dbd90..fa7eb6052 100644 --- a/app/controllers/avatar_controller.rb +++ b/app/controllers/avatar_controller.rb @@ -2,7 +2,7 @@ class AvatarController < ApplicationController #before_filter :set_cache_buster - include AvatarHelper + include AvatarHelper def upload # Make sure that API users get used to set this content type @@ -77,6 +77,40 @@ class AvatarController < ApplicationController } end end + + #add by zjc + #删除图片 + def delete_image + @source_type = params[:source_type] + @source_id = params[:source_id] + @source = nil #eval(@source_type).find(@source_id) + c = Object.const_get(@source_type) + if c.respond_to?(:find) + @source = c.find(@source_id) + end + + diskfile=disk_filename(@source_type,@source_id) + unless diskfile.nil? || diskfile == "" + path = File.dirname(diskfile) + if File.directory?(path) && File.exist?(diskfile) + File.delete(diskfile) + end + end + rescue e do + logger.info e.message + end + respond_to do |format| + format.js + format.api { + if saved + render :action => 'upload', :status => :created + else + render_validation_errors(@avatar) + end + } + end + + end private diff --git a/app/helpers/avatar_helper.rb b/app/helpers/avatar_helper.rb index 2ebdae0c8..3f6802f59 100644 --- a/app/helpers/avatar_helper.rb +++ b/app/helpers/avatar_helper.rb @@ -38,7 +38,7 @@ module AvatarHelper avatar_image(source) else File.join(relative_path,avatar_directory(source.class),'0') - end + end end def get_avatar?(source) diff --git a/app/views/admin/contest_page_made.html.erb b/app/views/admin/contest_page_made.html.erb index b8a86fa4d..a4407cd6b 100644 --- a/app/views/admin/contest_page_made.html.erb +++ b/app/views/admin/contest_page_made.html.erb @@ -17,7 +17,7 @@

-
+
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %>

diff --git a/app/views/admin/course_page_made.html.erb b/app/views/admin/course_page_made.html.erb index 4554fb8e0..7d73c7c6e 100644 --- a/app/views/admin/course_page_made.html.erb +++ b/app/views/admin/course_page_made.html.erb @@ -16,7 +16,7 @@

-
+
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %>

diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb index a64bbb443..d3b7416e4 100644 --- a/app/views/admin/first_page_made.html.erb +++ b/app/views/admin/first_page_made.html.erb @@ -16,7 +16,7 @@

-
+
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
diff --git a/app/views/avatar/_avatar_form.html.erb b/app/views/avatar/_avatar_form.html.erb index a880f32aa..6f9b9c7b1 100644 --- a/app/views/avatar/_avatar_form.html.erb +++ b/app/views/avatar/_avatar_form.html.erb @@ -1,3 +1,4 @@ +