课程留言,发邮件给课程所有人

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2015-01-21 11:33:29 +08:00
parent 9f36469d39
commit 6ccb154cc3
8 changed files with 72 additions and 5 deletions

2
.rspec Normal file
View File

@ -0,0 +1,2 @@
--format documentation
--color

View File

@ -111,6 +111,10 @@ module CoursesHelper
#garble count
# end
#获取课程所有成员
def course_member course
course.members
end
# 学生人数计算
# add by nwb
def studentCount course

View File

@ -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

View File

@ -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,

View File

@ -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)

View File

@ -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

View File

@ -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

38
spec/spec_helper.rb Normal file
View File

@ -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