From fd5747f4dc558eb9dd27c733c4b433da97e4faf0 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 14 Jul 2014 10:27:54 +0800 Subject: [PATCH 1/9] 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 87b623bc51e9680b60b1c766b6aaec75a5619451 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 14 Jul 2014 10:44:07 +0800 Subject: [PATCH 2/9] =?UTF-8?q?1.=E6=96=87=E6=A1=A3=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=E7=BA=A7=E8=AE=BE=E7=BD=AE=202.=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E3=80=81=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/document.rb | 2 +- app/views/documents/_form.html.erb | 5 ++++- config/locales/en.yml | 1 + config/locales/zh.yml | 1 + ...140714021812_add_is_public_to_documents.rb | 5 +++++ db/schema.rb | 22 +++---------------- 6 files changed, 15 insertions(+), 21 deletions(-) create mode 100644 db/migrate/20140714021812_add_is_public_to_documents.rb diff --git a/app/models/document.rb b/app/models/document.rb index 7c2730682..661949ca9 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -39,7 +39,7 @@ class Document < ActiveRecord::Base includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args)) } - safe_attributes 'category_id', 'title', 'description' + safe_attributes 'category_id', 'title', 'description','is_public' def visible?(user=User.current) !user.nil? && user.allowed_to?(:view_documents, project) diff --git a/app/views/documents/_form.html.erb b/app/views/documents/_form.html.erb index 53d8fc3bb..72361b9ab 100644 --- a/app/views/documents/_form.html.erb +++ b/app/views/documents/_form.html.erb @@ -1,7 +1,10 @@ <%= error_messages_for @document %>
-

<%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %>

+

<%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %>

+

<%= f.check_box :is_public, :style => "margin-left:10px;" %> + <%= l(:label_document_public_info) %> +

<%= f.text_field :title, :required => true, :size => 60 %>

<%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 6566564c9..db673c69c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -537,6 +537,7 @@ en: label_document_new: New document label_document_plural: Documents label_document_added: Document added + label_document_public_info: "If you don't choose public, only the project's members can see the document." label_role: Role label_role_plural: Roles label_role_new: New role diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 1be9e7b20..36d89da10 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -533,6 +533,7 @@ zh: label_document_new: 新建文档 label_document_plural: 文档 label_document_added: 文档已添加 + label_document_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该文档。) label_role: 角色 label_role_plural: 角色 label_role_new: 新建角色 diff --git a/db/migrate/20140714021812_add_is_public_to_documents.rb b/db/migrate/20140714021812_add_is_public_to_documents.rb new file mode 100644 index 000000000..2c21c7d03 --- /dev/null +++ b/db/migrate/20140714021812_add_is_public_to_documents.rb @@ -0,0 +1,5 @@ +class AddIsPublicToDocuments < ActiveRecord::Migration + def change + add_column :documents, :is_public, :integer,:default => 1 + end +end diff --git a/db/schema.rb b/db/schema.rb index f63f3cb46..109c1f189 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -<<<<<<< HEAD -ActiveRecord::Schema.define(:version => 20140710030426) do -======= -ActiveRecord::Schema.define(:version => 20140708023356) do ->>>>>>> 056f86caad29ca95632d9da9e1e616cd00e2349a +ActiveRecord::Schema.define(:version => 20140714021812) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -383,6 +379,7 @@ ActiveRecord::Schema.define(:version => 20140708023356) 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" @@ -799,7 +796,7 @@ ActiveRecord::Schema.define(:version => 20140708023356) do end create_table "relative_memos", :force => true do |t| - t.integer "osp_id", :null => false + t.integer "osp_id" t.integer "parent_id" t.string "subject", :null => false t.text "content", :null => false @@ -836,19 +833,6 @@ ActiveRecord::Schema.define(:version => 20140708023356) do add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - create_table "roles", :force => true do |t| t.string "name", :limit => 30, :default => "", :null => false t.integer "position", :default => 1 From 0031f90c649f95ee856a3eae67971f654f77f15d Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 14 Jul 2014 11:31:24 +0800 Subject: [PATCH 3/9] =?UTF-8?q?1.=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=A7=81=E6=9C=89=E7=9A=84=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E3=80=81=E6=96=87=E6=A1=A3=E8=BF=9B=E8=A1=8C=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=88=A4=E6=96=AD=202.=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=A7=81=E6=9C=89=E7=9A=84=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E3=80=81=E6=96=87=E6=A1=A3=E8=BF=9B=E8=A1=8C=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 8 +++++++- app/controllers/documents_controller.rb | 9 +++++++++ app/controllers/projects_controller.rb | 10 ++++++++-- app/models/attachment.rb | 5 ++++- app/models/document.rb | 3 ++- .../lib/acts_as_activity_provider.rb | 7 ++++++- lib/redmine/activity/fetcher.rb | 2 ++ 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 27851e435..a38d9f9c8 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -630,7 +630,13 @@ class CoursesController < ApplicationController :with_subprojects => false, :author => @author) @activity.scope_select {|t| has["show_#{t}"]} - events = @activity.events(@date_from, @date_to) + # modify by nwb + # 添加私密性判断 + if User.current.member_of_course?(@course)|| User.current.admin? + events = @activity.events(@date_from, @date_to) + else + events = @activity.events(@date_from, @date_to, :is_public => 1) + end @offset, @limit = api_offset_and_limit({:limit => 10}) @events_count = events.count diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 464c4a2b8..89bd9dc92 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -23,6 +23,7 @@ class DocumentsController < ApplicationController before_filter :find_model_object, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create] before_filter :authorize , :except => [:index]#Added by young + before_filter :authorize_document helper :attachments @@ -100,4 +101,12 @@ class DocumentsController < ApplicationController end redirect_to document_path(@document) end + + # 权限判断 + # add by nwb + def authorize_document + if !(User.current.admin? || User.current.member_of?(@project) || @document.is_public==1) + render_403 :message => :notice_not_authorized + end + end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a840ee934..1d3f0ec42 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -697,8 +697,14 @@ class ProjectsController < ApplicationController @activity.scope_select {|t| !has["show_#{t}"].nil?} # logger.debug "=========================================#{@activity.scope}" # @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? - #Added by young - events = @activity.events(@date_from, @date_to) + + # modify by nwb + # 添加私密性判断 + if User.current.member_of?(@project)|| User.current.admin? + events = @activity.events(@date_from, @date_to) + else + events = @activity.events(@date_from, @date_to, :is_public => 1) + end @offset, @limit = api_offset_and_limit({:limit => 10}) @events_count = events.count diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 0eb3e7666..b301ba73c 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -39,19 +39,22 @@ class Attachment < ActiveRecord::Base #课程资源文件 acts_as_activity_provider :type => 'course_files', + :is_public => 'attachments.is_public', :permission => :view_files, :author_key => :author_id, :find_options => {:select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Course.table_name} ON ( #{Attachment.table_name}.container_type='Course' AND #{Attachment.table_name}.container_id = #{Course.table_name}.id )"} acts_as_activity_provider :type => 'files', + :is_public => 'attachments.is_public', :permission => :view_files, :author_key => :author_id, - :find_options => {:select => "#{Attachment.table_name}.*", + :find_options => { :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " + "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )"} acts_as_activity_provider :type => 'documents', + :is_public => 'documents.is_public', :permission => :view_documents, :author_key => :author_id, :find_options => {:select => "#{Attachment.table_name}.*", diff --git a/app/models/document.rb b/app/models/document.rb index 661949ca9..5cfce896b 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -30,7 +30,8 @@ class Document < ActiveRecord::Base acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"}, :author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) }, :url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}} - acts_as_activity_provider :find_options => {:include => :project} + acts_as_activity_provider :find_options => {:include => :project}, + :is_public => 'documents.is_public' validates_presence_of :project, :title, :category validates_length_of :title, :maximum => 60 diff --git a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb index 3875d5c04..e671c3e22 100644 --- a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb +++ b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb @@ -29,7 +29,7 @@ module Redmine send :include, Redmine::Acts::ActivityProvider::InstanceMethods end - options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options, :func) + options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options, :func,:is_public) self.activity_provider_options ||= {} # One model can provide different event types @@ -65,6 +65,11 @@ module Redmine scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id]) end + # add by nwb + if options[:is_public] && !provider_options[:is_public].nil? + scope = scope.scoped(:conditions => ["#{provider_options[:is_public]} = ?", options[:is_public]]) + end + if options[:limit] # id and creation time should be in same order in most cases scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit]) diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb index b95ae2bc3..2caef48b8 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -82,6 +82,8 @@ module Redmine def events(from = nil, to = nil, options={}) e = [] @options[:limit] = options[:limit] + # modify by nwb + @options[:is_public] = options[:is_public] @scope.each do |event_type| constantized_providers(event_type).each do |provider| From 7a9b5156c9b787f4e0ceb1f0f2413f9d5f5d4eaa Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 14 Jul 2014 11:46:52 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BD=AF=E4=BB=B6?= =?UTF-8?q?=E5=88=9B=E5=AE=A2=E5=88=97=E8=A1=A8=E5=BD=93=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=A7=93=E5=90=8D=E6=AF=94=E8=BE=83=E9=95=BF=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A7=93=E5=90=8D=E4=BC=9A=E8=A2=AB=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E5=BE=97=E5=88=86=E8=A6=86=E7=9B=96=E6=8E=89=E7=9A=84?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_show.html.erb | 36 +- db/schema.rb | 1199 --------------------------- 2 files changed, 21 insertions(+), 1214 deletions(-) delete mode 100644 db/schema.rb diff --git a/app/views/users/_user_show.html.erb b/app/views/users/_user_show.html.erb index d6fa541c7..13f08f7ef 100644 --- a/app/views/users/_user_show.html.erb +++ b/app/views/users/_user_show.html.erb @@ -33,21 +33,27 @@ <%= image_tag "/images/time_member.png", :class => "img_member_time"%>
- <%= image_tag(url_to_avatar(user), :class => 'avatar') %> - <%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %> - - -
- - <%= render :partial => 'users/user_score', :locals => {:user => user}%> -
- -
- -
- <%= l(:label_x_has_fans,:count=>user.watcher_users.count)%> - <%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %> - + + + + + + + + + +
+ <%= image_tag(url_to_avatar(user), :class => 'avatar') %> + + <%= link_to_user(user) %> + + + <%= render :partial => 'users/user_score', :locals => {:user => user}%> + +
+ <%= l(:label_x_has_fans,:count=>user.watcher_users.count)%> + <%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %> +
<% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> diff --git a/db/schema.rb b/db/schema.rb deleted file mode 100644 index fa41ed1d5..000000000 --- a/db/schema.rb +++ /dev/null @@ -1,1199 +0,0 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20140711012924) do - - create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - end - - add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" - add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" - add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - - create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "attachments", :force => true do |t| - t.integer "container_id" - t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype", :default => 1 - t.integer "is_public", :default => 1 - end - - add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" - add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" - add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - - create_table "auth_sources", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 60, :default => "", :null => false - t.string "host", :limit => 60 - t.integer "port" - t.string "account" - t.string "account_password", :default => "" - t.string "base_dn" - t.string "attr_login", :limit => 30 - t.string "attr_firstname", :limit => 30 - t.string "attr_lastname", :limit => 30 - t.string "attr_mail", :limit => 30 - t.boolean "onthefly_register", :default => false, :null => false - t.boolean "tls", :default => false, :null => false - t.string "filter" - t.integer "timeout" - end - - add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - - create_table "biding_projects", :force => true do |t| - t.integer "project_id" - t.integer "bid_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "bids", :force => true do |t| - t.string "name" - t.string "budget", :null => false - t.integer "author_id" - t.date "deadline" - t.string "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.integer "commit" - t.integer "reward_type" - t.integer "homework_type" - t.integer "parent_id" - t.string "password" - t.integer "is_evaluation" - t.integer "proportion", :default => 60 - end - - create_table "boards", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :default => "", :null => false - t.string "description" - t.integer "position", :default => 1 - t.integer "topics_count", :default => 0, :null => false - t.integer "messages_count", :default => 0, :null => false - t.integer "last_message_id" - t.integer "parent_id" - t.integer "course_id" - end - - add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" - add_index "boards", ["project_id"], :name => "boards_project_id" - - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "changes", :force => true do |t| - t.integer "changeset_id", :null => false - t.string "action", :limit => 1, :default => "", :null => false - t.text "path", :null => false - t.text "from_path" - t.string "from_revision" - t.string "revision" - t.string "branch" - end - - add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" - - create_table "changeset_parents", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "parent_id", :null => false - end - - add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" - add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" - - create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false - t.string "committer" - t.datetime "committed_on", :null => false - t.text "comments" - t.date "commit_date" - t.string "scmid" - t.integer "user_id" - end - - add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" - add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true - add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" - add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" - add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" - - create_table "changesets_issues", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "issue_id", :null => false - end - - 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 - t.integer "author_id", :default => 0, :null => false - t.text "comments" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "comments", ["author_id"], :name => "index_comments_on_author_id" - add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" - - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.string "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contests", :force => true do |t| - t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - create_table "course_infos", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "course_id" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "courses", :force => true do |t| - t.integer "tea_id" - t.string "name" - t.integer "state" - t.string "code" - t.integer "time" - t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "location" - t.string "term" - t.string "string" - t.string "password" - t.string "setup_time" - t.string "endup_time" - t.string "class_period" - t.integer "school_id" - t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 - t.integer "lft" - t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - end - - create_table "custom_fields", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.string "field_format", :limit => 30, :default => "", :null => false - t.text "possible_values" - t.string "regexp", :default => "" - t.integer "min_length", :default => 0, :null => false - t.integer "max_length", :default => 0, :null => false - t.boolean "is_required", :default => false, :null => false - t.boolean "is_for_all", :default => false, :null => false - t.boolean "is_filter", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "searchable", :default => false - t.text "default_value" - t.boolean "editable", :default => true - t.boolean "visible", :default => true, :null => false - t.boolean "multiple", :default => false - end - - add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" - - create_table "custom_fields_projects", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false - end - - add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true - - create_table "custom_fields_trackers", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true - - create_table "custom_values", :force => true do |t| - t.string "customized_type", :limit => 30, :default => "", :null => false - t.integer "customized_id", :default => 0, :null => false - t.integer "custom_field_id", :default => 0, :null => false - t.text "value" - end - - add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" - add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - - create_table "documents", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "category_id", :default => 0, :null => false - t.string "title", :limit => 60, :default => "", :null => false - t.text "description" - t.datetime "created_on" - t.integer "user_id", :default => 0 - end - - add_index "documents", ["category_id"], :name => "index_documents_on_category_id" - add_index "documents", ["created_on"], :name => "index_documents_on_created_on" - add_index "documents", ["project_id"], :name => "documents_project_id" - - create_table "enabled_modules", :force => true do |t| - t.integer "project_id" - t.string "name", :null => false - t.integer "course_id" - end - - add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" - - create_table "enumerations", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "is_default", :default => false, :null => false - t.string "type" - t.boolean "active", :default => true, :null => false - t.integer "project_id" - t.integer "parent_id" - t.string "position_name", :limit => 30 - end - - add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" - add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - - create_table "first_pages", :force => true do |t| - t.string "web_title" - t.string "title" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "page_type" - end - - create_table "forums", :force => true do |t| - t.string "name", :null => false - t.string "description", :default => "" - t.integer "topic_count", :default => 0 - t.integer "memo_count", :default => 0 - t.integer "last_memo_id", :default => 0 - t.integer "creator_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "groups_users", :id => false, :force => true do |t| - t.integer "group_id", :null => false - t.integer "user_id", :null => false - end - - add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - - create_table "homework_attaches", :force => true do |t| - t.integer "bid_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - t.string "name" - t.string "description" - t.integer "state" - t.integer "project_id", :default => 0 - end - - create_table "homework_for_courses", :force => true do |t| - t.integer "course_id" - t.integer "bid_id" - end - - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "issue_categories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.integer "assigned_to_id" - end - - add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" - add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" - - create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false - t.integer "delay" - end - - add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true - add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" - add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" - - create_table "issue_statuses", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_closed", :default => false, :null => false - t.boolean "is_default", :default => false, :null => false - t.integer "position", :default => 1 - t.integer "default_done_ratio" - end - - add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" - add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" - add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" - - create_table "issues", :force => true do |t| - t.integer "tracker_id", :null => false - t.integer "project_id", :null => false - t.string "subject", :default => "", :null => false - t.text "description" - t.date "due_date" - t.integer "category_id" - t.integer "status_id", :null => false - t.integer "assigned_to_id" - t.integer "priority_id", :null => false - t.integer "fixed_version_id" - t.integer "author_id", :null => false - t.integer "lock_version", :default => 0, :null => false - t.datetime "created_on" - t.datetime "updated_on" - t.date "start_date" - t.integer "done_ratio", :default => 0, :null => false - t.float "estimated_hours" - t.integer "parent_id" - t.integer "root_id" - t.integer "lft" - t.integer "rgt" - t.boolean "is_private", :default => false, :null => false - t.datetime "closed_on" - end - - add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["category_id"], :name => "index_issues_on_category_id" - add_index "issues", ["created_on"], :name => "index_issues_on_created_on" - add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" - add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" - add_index "issues", ["project_id"], :name => "issues_project_id" - add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" - add_index "issues", ["status_id"], :name => "index_issues_on_status_id" - add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "join_in_contests", :force => true do |t| - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "journal_details", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_replies", :id => false, :force => true do |t| - t.integer "journal_id" - t.integer "user_id" - t.integer "reply_id" - end - - add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" - add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" - add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" - - create_table "journals", :force => true do |t| - t.integer "journalized_id", :default => 0, :null => false - t.string "journalized_type", :limit => 30, :default => "", :null => false - t.integer "user_id", :default => 0, :null => false - t.text "notes" - t.datetime "created_on", :null => false - t.boolean "private_notes", :default => false, :null => false - end - - add_index "journals", ["created_on"], :name => "index_journals_on_created_on" - add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" - add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" - add_index "journals", ["user_id"], :name => "index_journals_on_user_id" - - create_table "journals_for_messages", :force => true do |t| - t.integer "jour_id" - t.string "jour_type" - t.integer "user_id" - t.text "notes" - t.integer "status" - t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.string "m_parent_id" - t.boolean "is_readed" - t.integer "m_reply_count" - t.integer "m_reply_id" - t.integer "is_comprehensive_evaluation" - end - - create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false - t.integer "inherited_from" - end - - add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" - add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" - - create_table "members", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0 - t.datetime "created_on" - t.boolean "mail_notification", :default => false, :null => false - t.integer "course_id", :default => -1 - end - - add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - add_index "members", ["user_id"], :name => "index_members_on_user_id" - - create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 - end - - create_table "messages", :force => true do |t| - t.integer "board_id", :null => false - t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false - t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - end - - add_index "messages", ["author_id"], :name => "index_messages_on_author_id" - add_index "messages", ["board_id"], :name => "messages_board_id" - add_index "messages", ["created_on"], :name => "index_messages_on_created_on" - add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" - add_index "messages", ["parent_id"], :name => "messages_parent_id" - - create_table "news", :force => true do |t| - t.integer "project_id" - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - end - - add_index "news", ["author_id"], :name => "index_news_on_author_id" - add_index "news", ["created_on"], :name => "index_news_on_created_on" - add_index "news", ["project_id"], :name => "news_project_id" - - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "notificationcomments", :force => true do |t| - t.string "notificationcommented_type" - t.integer "notificationcommented_id" - t.integer "author_id" - t.text "notificationcomments" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "open_id_authentication_associations", :force => true do |t| - t.integer "issued" - t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" - end - - create_table "open_id_authentication_nonces", :force => true do |t| - t.integer "timestamp", :null => false - t.string "server_url" - t.string "salt", :null => false - end - - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_tread_caches", :force => true do |t| - t.integer "object_id", :null => false - t.string "object_type" - t.integer "praise_num" - t.integer "tread_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_treads", :force => true do |t| - t.integer "user_id", :null => false - t.integer "praise_tread_object_id" - t.string "praise_tread_object_type" - t.integer "praise_or_tread" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_infos", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "project_id" - t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - end - - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false - t.integer "parent_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "identifier" - t.integer "status", :default => 1, :null => false - t.integer "lft" - t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false - t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 - t.integer "user_id" - end - - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - - create_table "projects_trackers", :id => false, :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true - add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - - create_table "queries", :force => true do |t| - t.integer "project_id" - t.string "name", :default => "", :null => false - t.text "filters" - t.integer "user_id", :default => 0, :null => false - t.boolean "is_public", :default => false, :null => false - t.text "column_names" - t.text "sort_criteria" - t.string "group_by" - t.string "type" - end - - add_index "queries", ["project_id"], :name => "index_queries_on_project_id" - add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - 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.integer "author_id" - 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.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" - end - - create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" - t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 - t.text "extra_info" - t.string "identifier" - t.boolean "is_default", :default => false - end - - add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - - create_table "roles", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "assignable", :default => true - t.integer "builtin", :default => 0, :null => false - t.text "permissions" - t.string "issues_visibility", :limit => 30, :default => "default", :null => false - end - - create_table "schools", :force => true do |t| - t.string "name" - t.string "province" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "logo_link" - end - - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "settings", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "value" - t.datetime "updated_on" - end - - add_index "settings", ["name"], :name => "index_settings_on_name" - - create_table "shares", :force => true do |t| - t.date "created_on" - t.string "url" - t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - t.integer "user_id" - t.string "description" - end - - create_table "softapplications", :force => true do |t| - t.string "name" - t.string "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" - end - - create_table "students_for_courses", :force => true do |t| - t.integer "student_id" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", :limit => 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" - - create_table "tags", :force => true do |t| - t.string "name" - end - - create_table "teachers", :force => true do |t| - t.string "tea_name" - t.string "location" - t.integer "couurse_time" - t.integer "course_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extra" - end - - create_table "time_entries", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "issue_id" - t.float "hours", :null => false - t.string "comments" - t.integer "activity_id", :null => false - t.date "spent_on", :null => false - t.integer "tyear", :null => false - t.integer "tmonth", :null => false - t.integer "tweek", :null => false - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" - add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" - add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" - add_index "time_entries", ["project_id"], :name => "time_entries_project_id" - add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - - create_table "tokens", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false - t.datetime "created_on", :null => false - end - - add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" - add_index "tokens", ["value"], :name => "tokens_value", :unique => true - - create_table "trackers", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_in_chlog", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "is_in_roadmap", :default => true, :null => false - t.integer "fields_bits", :default => 0 - end - - create_table "user_extensions", :force => true do |t| - t.integer "user_id", :null => false - t.date "birthday" - t.string "brief_introduction" - t.integer "gender" - t.string "location" - t.string "occupation" - t.integer "work_experience" - t.integer "zip_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "technical_title" - t.integer "identity" - t.string "student_id" - t.string "teacher_realname" - t.string "student_realname" - t.string "location_city" - t.integer "school_id" - end - - create_table "user_grades", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.float "grade", :default => 0.0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" - add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" - add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - - create_table "user_preferences", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.text "others" - t.boolean "hide_mail", :default => false - t.string "time_zone" - end - - add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" - - create_table "user_score_details", :force => true do |t| - t.integer "current_user_id" - t.integer "target_user_id" - t.string "score_type" - t.string "score_action" - t.integer "user_id" - t.integer "old_score" - t.integer "new_score" - t.integer "current_user_level" - t.integer "target_user_level" - t.integer "score_changeable_obj_id" - t.string "score_changeable_obj_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "grade", :default => 0.0 - end - - add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" - add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" - add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - - create_table "users", :force => true do |t| - t.string "login", :default => "", :null => false - t.string "hashed_password", :limit => 40, :default => "", :null => false - t.string "firstname", :limit => 30, :default => "", :null => false - t.string "lastname", :default => "", :null => false - t.string "mail", :limit => 60, :default => "", :null => false - t.boolean "admin", :default => false, :null => false - t.integer "status", :default => 1, :null => false - t.datetime "last_login_on" - t.string "language", :limit => 5, :default => "" - t.integer "auth_source_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "type" - t.string "identity_url" - t.string "mail_notification", :default => "", :null => false - t.string "salt", :limit => 64 - end - - add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" - add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" - add_index "users", ["type"], :name => "index_users_on_type" - - create_table "versions", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :default => "", :null => false - t.string "description", :default => "" - t.date "effective_date" - t.datetime "created_on" - t.datetime "updated_on" - t.string "wiki_page_title" - t.string "status", :default => "open" - t.string "sharing", :default => "none", :null => false - end - - add_index "versions", ["project_id"], :name => "versions_project_id" - add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - - create_table "watchers", :force => true do |t| - t.string "watchable_type", :default => "", :null => false - t.integer "watchable_id", :default => 0, :null => false - t.integer "user_id" - end - - add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" - add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" - add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" - - create_table "wiki_content_versions", :force => true do |t| - t.integer "wiki_content_id", :null => false - t.integer "page_id", :null => false - t.integer "author_id" - t.binary "data", :limit => 2147483647 - t.string "compression", :limit => 6, :default => "" - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" - add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" - - create_table "wiki_contents", :force => true do |t| - t.integer "page_id", :null => false - t.integer "author_id" - t.text "text", :limit => 2147483647 - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" - add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" - - create_table "wiki_pages", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title", :null => false - t.datetime "created_on", :null => false - t.boolean "protected", :default => false, :null => false - t.integer "parent_id" - end - - add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" - add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" - add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" - - create_table "wiki_redirects", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title" - t.string "redirects_to" - t.datetime "created_on", :null => false - end - - add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" - add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" - - create_table "wikis", :force => true do |t| - t.integer "project_id", :null => false - t.string "start_page", :null => false - t.integer "status", :default => 1, :null => false - end - - add_index "wikis", ["project_id"], :name => "wikis_project_id" - - create_table "workflows", :force => true do |t| - t.integer "tracker_id", :default => 0, :null => false - t.integer "old_status_id", :default => 0, :null => false - t.integer "new_status_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - t.boolean "assignee", :default => false, :null => false - t.boolean "author", :default => false, :null => false - t.string "type", :limit => 30 - t.string "field_name", :limit => 30 - t.string "rule", :limit => 30 - end - - add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" - add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" - add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" - add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - -end From 31245f6fb2c7af4b1d551f8937b9f28e7effefac Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 14 Jul 2014 13:55:22 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BD=AF=E4=BB=B6?= =?UTF-8?q?=E5=88=9B=E5=AE=A2=E5=88=97=E8=A1=A8=E4=B8=AD=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E7=94=A8=E6=88=B7=E5=90=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E4=B8=BA=E8=B6=85=E9=93=BE=E6=8E=A5(?= =?UTF-8?q?=E6=9C=AA=E6=BF=80=E6=B4=BB=E8=B4=A6=E6=88=B7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4f6cb3e95..bf125972b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -80,11 +80,12 @@ module ApplicationHelper name = h(user.name(options[:format])) 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 - else - name - 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 + #else + # name + #end + link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes else h(user.to_s) end From 2a1a0513624a35a53263d22b63b198f7ccc00003 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 14 Jul 2014 15:15:28 +0800 Subject: [PATCH 6/9] =?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 7/9] =?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 e6b80de3b5954d3bbf0e90ecfa25d4b6f3d0a372 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 14 Jul 2014 16:51:18 +0800 Subject: [PATCH 8/9] =?UTF-8?q?rmagick=E8=B0=83=E6=95=B4=E4=B8=BA=E4=BB=85?= =?UTF-8?q?test=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 9/9] 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