spec: fix several AR::Base specs for rails 3
* don't define message on Object. that's scary * change some deprecated rspec syntax * pend fake_arel specs in rails 3 Change-Id: Ib53f4bfd8edc24be48e1e8b29162fa1210175bc5 Reviewed-on: https://gerrit.instructure.com/29280 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: James Williams <jamesw@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
1990a81baa
commit
50edbe1517
|
@ -371,7 +371,7 @@ describe ActiveRecord::Base do
|
|||
end
|
||||
|
||||
it "should not raise an error if there are no records" do
|
||||
expect { Course.bulk_insert [] }.should change(Course, :count).by(0)
|
||||
expect { Course.bulk_insert [] }.to change(Course, :count).by(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -480,15 +480,15 @@ describe ActiveRecord::Base do
|
|||
end
|
||||
|
||||
it "should fail with improper nested hashes" do
|
||||
lambda {
|
||||
expect {
|
||||
User.where(:name => { :users => { :id => @user }}).first
|
||||
}.should raise_error(ActiveRecord::StatementInvalid)
|
||||
}.to raise_error(ActiveRecord::StatementInvalid)
|
||||
end
|
||||
|
||||
it "should fail with dot in nested column name" do
|
||||
lambda {
|
||||
expect {
|
||||
User.where(:name => { "users.id" => @user }).first
|
||||
}.should raise_error(ActiveRecord::StatementInvalid)
|
||||
}.to raise_error(ActiveRecord::StatementInvalid)
|
||||
end
|
||||
|
||||
it "should not fail with a dot in column name only" do
|
||||
|
@ -546,6 +546,7 @@ describe ActiveRecord::Base do
|
|||
|
||||
context "fake arel extensions" do
|
||||
before do
|
||||
pending "only apply to rails 2" unless CANVAS_RAILS2
|
||||
@user = User.create!(:name => 'a')
|
||||
@cc = @user.communication_channels.create!(:path => 'nobody@example.com')
|
||||
end
|
||||
|
|
|
@ -214,6 +214,23 @@ matchers_module.define :match_ignoring_whitespace do |expected|
|
|||
end
|
||||
end
|
||||
|
||||
module Helpers
|
||||
def message(opts={})
|
||||
m = Message.new
|
||||
m.to = opts[:to] || 'some_user'
|
||||
m.from = opts[:from] || 'some_other_user'
|
||||
m.subject = opts[:subject] || 'a message for you'
|
||||
m.body = opts[:body] || 'nice body'
|
||||
m.sent_at = opts[:sent_at] || 5.days.ago
|
||||
m.workflow_state = opts[:workflow_state] || 'sent'
|
||||
m.user_id = opts[:user_id] || opts[:user].try(:id)
|
||||
m.path_type = opts[:path_type] || 'email'
|
||||
m.root_account_id = opts[:account_id] || Account.default.id
|
||||
m.save!
|
||||
m
|
||||
end
|
||||
end
|
||||
|
||||
(CANVAS_RAILS2 ? Spec::Runner : RSpec).configure do |config|
|
||||
# If you're not using ActiveRecord you should remove these
|
||||
# lines, delete config/database.yml and disable :active_record
|
||||
|
@ -223,6 +240,7 @@ end
|
|||
config.fixture_path = Rails.root+'spec/fixtures/'
|
||||
|
||||
config.include Webrat::Matchers, :type => :views
|
||||
config.include Helpers
|
||||
|
||||
config.before :all do
|
||||
# so before(:all)'s don't get confused
|
||||
|
@ -801,21 +819,6 @@ end
|
|||
mo
|
||||
end
|
||||
|
||||
def message(opts={})
|
||||
m = Message.new
|
||||
m.to = opts[:to] || 'some_user'
|
||||
m.from = opts[:from] || 'some_other_user'
|
||||
m.subject = opts[:subject] || 'a message for you'
|
||||
m.body = opts[:body] || 'nice body'
|
||||
m.sent_at = opts[:sent_at] || 5.days.ago
|
||||
m.workflow_state = opts[:workflow_state] || 'sent'
|
||||
m.user_id = opts[:user_id] || opts[:user].try(:id)
|
||||
m.path_type = opts[:path_type] || 'email'
|
||||
m.root_account_id = opts[:account_id] || Account.default.id
|
||||
m.save!
|
||||
m
|
||||
end
|
||||
|
||||
def assert_status(status=500)
|
||||
response.status.to_i.should eql(status)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue