diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..8c18f1abd --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 411de1dcf..95b049dc2 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -111,6 +111,10 @@ module CoursesHelper #garble count # end + #获取课程所有成员 + def course_member course + course.members + end # 学生人数计算 # add by nwb def studentCount course diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb index 093002a2c..0e5f29d03 100644 --- a/app/models/journals_for_message_observer.rb +++ b/app/models/journals_for_message_observer.rb @@ -1,7 +1,9 @@ # Added by young class JournalsForMessageObserver < ActiveRecord::Observer def after_create(journals_for_message) + thread1 = Thread.start do Mailer.journals_for_message_add(User.current, journals_for_message).deliver + end end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 72e60a0bf..a2e742ee3 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -62,13 +62,13 @@ class Mailer < ActionMailer::Base course = journals_for_message.jour @author = journals_for_message.user #课程的教师 - @teachers = searchTeacherAndAssistant journals_for_message.jour + @members = course_member journals_for_message.jour #收件人邮箱 @recipients ||= [] - @teachers.each do |teacher| - if teacher.user.notify_about? journals_for_message + @members.each do |teacher| + @recipients << teacher.user.mail - end + end mail :to => @recipients, diff --git a/config/application.rb b/config/application.rb index 716e3875d..2f1534d00 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,6 +21,16 @@ module RedmineApp config.verifier_email = "lizanle521@126.com" end + config.generators do |g| + g.test_framework :rspec, + fixtures: true, + view_specs: false, + helper_specs: false, + routing_specs: false, + controller_specs: true, + request_specs: false + g.fixture_replacement :factory_girl, dir: "spec/factories" + end # Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += %W(#{config.root}/lib) diff --git a/db/migrate/20150121030451_add_initial_products.rb b/db/migrate/20150121030451_add_initial_products.rb new file mode 100644 index 000000000..cb6006068 --- /dev/null +++ b/db/migrate/20150121030451_add_initial_products.rb @@ -0,0 +1,11 @@ +class AddInitialProducts < ActiveRecord::Migration + def up + Forum.create(:name =>"new forum", :description => "", :topic_count => "0", + :memo_count => "0", :last_memo_id =>"0", :creator_id =>"2", + :sticky =>"0", :locked =>"0") + end + + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 2120080a0..7d10abc35 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 => 20150114022710) do +ActiveRecord::Schema.define(:version => 20150121030451) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 000000000..d2cbea7d9 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,38 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'rspec/autorun' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } + +RSpec.configure do |config| + # ## Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = "random" +end