Browse files

Updated specs to rspec 2.14

  • Loading branch information...
1 parent da75a34 commit 229d713f89f93bfdef0b8a52d65ffd6d78fd3731 @steveyken steveyken committed Aug 13, 2013
View
11 custom_plan.rb
@@ -0,0 +1,11 @@
+require 'zeus/rails'
+
+class CustomPlan < Zeus::Rails
+
+ # def my_custom_command
+ # # see https://github.com/burke/zeus/blob/master/docs/ruby/modifying.md
+ # end
+
+end
+
+Zeus.plan = CustomPlan.new
View
2 spec/controllers/admin/users_controller_spec.rb
@@ -241,7 +241,7 @@
xhr :delete, :destroy, :id => @user.id
flash[:warning].should_not == nil
- lambda { User.find(@user) }.should_not raise_error(ActiveRecord::RecordNotFound)
+ expect { User.find(@user) }.not_to raise_error()
response.should render_template("admin/users/destroy")
end
end
View
4 spec/controllers/applications_controller_spec.rb
@@ -23,7 +23,7 @@
it "should return [6, 9] when related is 'campaigns/7'" do
controller.stub(:controller_name).and_return('opportunities')
- campaign = mock(Campaign, :opportunities => [mock(:id => 6), mock(:id => 9)])
+ campaign = double(Campaign, :opportunities => [double(:id => 6), double(:id => 9)])
Campaign.should_receive(:find_by_id).with('7').and_return(campaign)
controller.send(:auto_complete_ids_to_exclude, 'campaigns/7').sort.should == [6, 9]
end
@@ -35,7 +35,7 @@
it "should return [] when related object association is not found" do
controller.stub(:controller_name).and_return('not_a_method_that_exists')
- campaign = mock(Campaign)
+ campaign = double(Campaign)
Campaign.should_receive(:find_by_id).with('7').and_return(campaign)
controller.send(:auto_complete_ids_to_exclude, 'campaigns/7').should == []
end
View
2 spec/controllers/authentications_controller_spec.rb
@@ -63,7 +63,7 @@
describe "POST authentications" do
before(:each) do
@login = { :username => "user", :password => "pass", :remember_me => "0" }
- @authentication = mock(Authentication, @login)
+ @authentication = double(Authentication, @login)
end
describe "successful authentication " do
View
4 spec/controllers/entities/accounts_controller_spec.rb
@@ -96,7 +96,7 @@ def get_data_for_sidebar
describe "with mime type of JSON" do
it "should render all accounts as json" do
- @controller.should_receive(:get_accounts).and_return(accounts = mock("Array of Accounts"))
+ @controller.should_receive(:get_accounts).and_return(accounts = double("Array of Accounts"))
accounts.should_receive(:to_json).and_return("generated JSON")
request.env["HTTP_ACCEPT"] = "application/json"
@@ -107,7 +107,7 @@ def get_data_for_sidebar
describe "with mime type of XML" do
it "should render all accounts as xml" do
- @controller.should_receive(:get_accounts).and_return(accounts = mock("Array of Accounts"))
+ @controller.should_receive(:get_accounts).and_return(accounts = double("Array of Accounts"))
accounts.should_receive(:to_xml).and_return("generated XML")
request.env["HTTP_ACCEPT"] = "application/xml"
View
4 spec/controllers/entities/contacts_controller_spec.rb
@@ -70,7 +70,7 @@
describe "with mime type of JSON" do
it "should render all contacts as JSON" do
- @controller.should_receive(:get_contacts).and_return(contacts = mock("Array of Contacts"))
+ @controller.should_receive(:get_contacts).and_return(contacts = double("Array of Contacts"))
contacts.should_receive(:to_json).and_return("generated JSON")
request.env["HTTP_ACCEPT"] = "application/json"
@@ -81,7 +81,7 @@
describe "with mime type of XML" do
it "should render all contacts as xml" do
- @controller.should_receive(:get_contacts).and_return(contacts = mock("Array of Contacts"))
+ @controller.should_receive(:get_contacts).and_return(contacts = double("Array of Contacts"))
contacts.should_receive(:to_xml).and_return("generated XML")
request.env["HTTP_ACCEPT"] = "application/xml"
View
4 spec/controllers/entities/leads_controller_spec.rb
@@ -95,7 +95,7 @@
describe "with mime type of JSON" do
it "should render all leads as JSON" do
- @controller.should_receive(:get_leads).and_return(leads = mock("Array of Leads"))
+ @controller.should_receive(:get_leads).and_return(leads = double("Array of Leads"))
leads.should_receive(:to_json).and_return("generated JSON")
request.env["HTTP_ACCEPT"] = "application/json"
@@ -106,7 +106,7 @@
describe "with mime type of XML" do
it "should render all leads as xml" do
- @controller.should_receive(:get_leads).and_return(leads = mock("Array of Leads"))
+ @controller.should_receive(:get_leads).and_return(leads = double("Array of Leads"))
leads.should_receive(:to_xml).and_return("generated XML")
request.env["HTTP_ACCEPT"] = "application/xml"
View
6 spec/controllers/entities/opportunities_controller_spec.rb
@@ -99,7 +99,7 @@ def get_data_for_sidebar
describe "with mime type of JSON" do
it "should render all opportunities as JSON" do
- @controller.should_receive(:get_opportunities).and_return(opportunities = mock("Array of Opportunities"))
+ @controller.should_receive(:get_opportunities).and_return(opportunities = double("Array of Opportunities"))
opportunities.should_receive(:to_json).and_return("generated JSON")
request.env["HTTP_ACCEPT"] = "application/json"
@@ -110,7 +110,7 @@ def get_data_for_sidebar
describe "with mime type of JSON" do
it "should render all opportunities as JSON" do
- @controller.should_receive(:get_opportunities).and_return(opportunities = mock("Array of Opportunities"))
+ @controller.should_receive(:get_opportunities).and_return(opportunities = double("Array of Opportunities"))
opportunities.should_receive(:to_json).and_return("generated JSON")
request.env["HTTP_ACCEPT"] = "application/json"
@@ -121,7 +121,7 @@ def get_data_for_sidebar
describe "with mime type of XML" do
it "should render all opportunities as xml" do
- @controller.should_receive(:get_opportunities).and_return(opportunities = mock("Array of Opportunities"))
+ @controller.should_receive(:get_opportunities).and_return(opportunities = double("Array of Opportunities"))
opportunities.should_receive(:to_xml).and_return("generated XML")
request.env["HTTP_ACCEPT"] = "application/xml"
View
4 spec/controllers/home_controller_spec.rb
@@ -157,8 +157,8 @@
describe "activity_user" do
before(:each) do
- @user = mock(User, :id => 1, :is_a? => true)
- @cur_user = mock(User)
+ @user = double(User, :id => 1, :is_a? => true)
+ @cur_user = double(User)
end
it "should find a user by email" do
View
4 spec/controllers/tasks_controller_spec.rb
@@ -120,7 +120,7 @@ def produce_tasks(user, view)
TASK_STATUSES.each do |view|
it "should render the requested task as JSON for #{view} view" do
- Task.stub_chain(:tracked_by, :find).and_return(task = mock("Task"))
+ Task.stub_chain(:tracked_by, :find).and_return(task = double("Task"))
task.should_receive(:to_json).and_return("generated JSON")
request.env["HTTP_ACCEPT"] = "application/json"
@@ -129,7 +129,7 @@ def produce_tasks(user, view)
end
it "should render the requested task as xml for #{view} view" do
- Task.stub_chain(:tracked_by, :find).and_return(task = mock("Task"))
+ Task.stub_chain(:tracked_by, :find).and_return(task = double("Task"))
task.should_receive(:to_xml).and_return("generated XML")
request.env["HTTP_ACCEPT"] = "application/xml"
View
4 spec/controllers/users_controller_spec.rb
@@ -35,7 +35,7 @@
end
it "should render the requested user as JSON" do
- User.should_receive(:find).and_return(user = mock("User"))
+ User.should_receive(:find).and_return(user = double("User"))
user.should_receive(:to_json).and_return("generated JSON")
get :show, :id => 42
@@ -56,7 +56,7 @@
end
it "should render the requested user as XML" do
- User.should_receive(:find).and_return(user = mock("User"))
+ User.should_receive(:find).and_return(user = double("User"))
user.should_receive(:to_xml).and_return("generated XML")
get :show, :id => 42
View
58 spec/lib/fields_spec.rb
@@ -21,82 +21,82 @@ class Bar
it do
Foo.new.should respond_to(:field_groups)
end
-
+
it do
Foo.should respond_to(:serialize_custom_fields!)
end
-
+
it do
Foo.should respond_to(:fields)
end
-
+
it "calling has_fields should invoke serialize_custom_fields!" do
Bar.should_receive(:serialize_custom_fields!)
Bar.has_fields
end
-
+
describe "field_groups" do
-
+
it "should call FieldGroup" do
ActiveRecord::Base.connection.should_receive(:table_exists?).with('field_groups').and_return(true)
- dummy_scope = mock
+ dummy_scope = double
dummy_scope.should_receive(:order).with(:position)
FieldGroup.should_receive(:where).and_return(dummy_scope)
Foo.new.field_groups
end
-
+
it "should not call FieldGroup if table doesn't exist (migrations not yet run)" do
ActiveRecord::Base.connection.should_receive(:table_exists?).with('field_groups').and_return(false)
Foo.new.field_groups.should == []
end
-
+
end
-
+
describe "fields" do
-
+
before(:each) do
- @f1 = mock(Field)
- @f2 = mock(Field)
- @f3 = mock(Field)
- @field_groups = [mock(FieldGroup, :fields => [@f1, @f2]), mock(FieldGroup, :fields => [@f3])]
+ @f1 = double(Field)
+ @f2 = double(Field)
+ @f3 = double(Field)
+ @field_groups = [double(FieldGroup, :fields => [@f1, @f2]), double(FieldGroup, :fields => [@f3])]
end
-
+
it "should convert field_groups into a flattened list of fields" do
Foo.should_receive(:field_groups).and_return(@field_groups)
Foo.fields.should == [@f1, @f2, @f3]
end
-
+
end
-
+
describe "serialize_custom_fields!" do
-
+
before(:each) do
- @f1 = mock(Field, :as => 'check_boxes', :name => 'field1')
- @f2 = mock(Field, :as => 'date', :name => 'field2')
+ @f1 = double(Field, :as => 'check_boxes', :name => 'field1')
+ @f2 = double(Field, :as => 'date', :name => 'field2')
end
-
+
it "should serialize checkbox fields as Array" do
Foo.stub(:serialized_attributes).and_return( {:field1 => @f1, :field2 => @f2} )
Foo.should_receive(:fields).and_return([@f1, @f2])
Foo.should_receive(:serialize).with(:field1, Array)
Foo.serialize_custom_fields!
end
-
+
end
-
+
it "should validate custom fields" do
foo = Foo.new
foo.should_receive(:custom_fields_validator)
foo.should be_valid
end
-
+
describe "custom_fields_validator" do
-
+
before(:each) do
- @f1 = mock(Field)
- @field_groups = [ mock(FieldGroup, :fields => [@f1]) ]
+ @f1 = double(Field)
+ @field_groups = [ double(FieldGroup, :fields => [@f1]) ]
end
-
+
it "should call custom_validator on each custom field" do
foo = Foo.new
@f1.should_receive(:custom_validator).with(foo)
@@ -105,5 +105,5 @@ class Bar
end
end
-
+
end
View
8 spec/lib/mail_processor/base_spec.rb
@@ -67,7 +67,7 @@
describe "Discarding a message" do
before(:each) do
mock_connect
- @uid = mock
+ @uid = double
@crawler.send(:connect!)
end
@@ -90,7 +90,7 @@
describe "Archiving a message" do
before(:each) do
mock_connect
- @uid = mock
+ @uid = double
@crawler.send(:connect!)
end
@@ -112,7 +112,7 @@
#------------------------------------------------------------------------------
describe "Validating email" do
before(:each) do
- @email = mock
+ @email = double
end
it "should be valid email if its contents type is text/plain" do
@@ -130,7 +130,7 @@
describe "Finding email sender among users" do
before(:each) do
@from = [ "Aaron@Example.Com", "Ben@Example.com" ]
- @email = mock
+ @email = double
@email.stub(:from).and_return(@from)
end
View
2 spec/models/entities/opportunity_spec.rb
@@ -37,7 +37,7 @@
it "should be possible to create opportunity with the same name" do
first = FactoryGirl.create(:opportunity, :name => "Hello", :user => current_user)
- lambda { FactoryGirl.create(:opportunity, :name => "Hello", :user => current_user) }.should_not raise_error(ActiveRecord::RecordInvalid)
+ expect { FactoryGirl.create(:opportunity, :name => "Hello", :user => current_user) }.to_not raise_error()
end
it "have a default stage" do
View
24 spec/models/fields/custom_field_date_pair_spec.rb
@@ -18,22 +18,22 @@
end
it "should be from..." do
- foo = mock(:cf_event_from => @today, :cf_event_to => nil)
+ foo = double(:cf_event_from => @today, :cf_event_to => nil)
@from.render_value(foo).should == "From #{@today_str}"
end
it "should be until..." do
- foo = mock(:cf_event_from => nil, :cf_event_to => @today)
+ foo = double(:cf_event_from => nil, :cf_event_to => @today)
@from.render_value(foo).should == "Until #{@today_str}"
end
it "should be from ... to" do
- foo = mock(:cf_event_from => @today, :cf_event_to => @today)
+ foo = double(:cf_event_from => @today, :cf_event_to => @today)
@from.render_value(foo).should == "From #{@today_str} to #{@today_str}"
end
it "should be empty string" do
- foo = mock(:cf_event_from => nil, :cf_event_to => nil)
+ foo = double(:cf_event_from => nil, :cf_event_to => nil)
@from.render_value(foo).should == ""
end
@@ -50,41 +50,41 @@
end
it "when from is nil it should be valid" do
- foo = mock(:cf_event_from => nil, :cf_event_to => @today)
+ foo = double(:cf_event_from => nil, :cf_event_to => @today)
foo.should_not_receive(:errors)
@to.custom_validator(foo)
end
it "when to is nil it should be valid" do
- foo = mock(:cf_event_from => @today, :cf_event_to => nil)
+ foo = double(:cf_event_from => @today, :cf_event_to => nil)
foo.should_not_receive(:errors)
@to.custom_validator(foo)
end
it "when from <= to it should be valid" do
- foo = mock(:cf_event_from => @today, :cf_event_to => @today)
+ foo = double(:cf_event_from => @today, :cf_event_to => @today)
foo.should_not_receive(:errors)
@to.custom_validator(foo)
end
it "when from > to it should not be valid" do
- foo = mock(:cf_event_from => @today, :cf_event_to => @today - 1.day)
- err = mock(:errors); err.stub(:add)
+ foo = double(:cf_event_from => @today, :cf_event_to => @today - 1.day)
+ err = double(:errors); err.stub(:add)
foo.should_receive(:errors).and_return(err)
@to.custom_validator(foo)
end
it "should ignore validation when called on from" do
- foo = mock(:cf_event_from => @today, :cf_event_to => @today - 1.day)
+ foo = double(:cf_event_from => @today, :cf_event_to => @today - 1.day)
foo.should_not_receive(:errors)
CustomFieldPair.should_not_receive(:find)
@from.custom_validator(foo)
end
it "should call custom field validation on super class" do
from = CustomFieldDatePair.new(:name => 'cf_event_from', :required => true)
- foo = mock(:cf_event_from => nil)
- err = mock(:errors); err.stub(:add)
+ foo = double(:cf_event_from => nil)
+ err = double(:errors); err.stub(:add)
foo.should_receive(:errors).and_return(err)
from.custom_validator(foo)
end
View
26 spec/models/fields/custom_field_pair_spec.rb
@@ -13,31 +13,31 @@ class CustomFieldFooPair
it "should respond to pair" do
CustomFieldPair.new.should respond_to(:pair)
end
-
+
describe "create_pair" do
-
+
before(:each) do
@field = {'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event'}
@pair1 = {'name' => 'pair1'}
@pair2 = {'name' => 'pair2'}
@params = { 'field' => @field, 'pair' => {'0' => @pair1, '1' => @pair2} }
end
-
+
it "should create the pair" do
params1 = @field.merge(@pair1)
- foo1 = mock(:id => 3, :required => true, :disabled => 'false')
+ foo1 = double(:id => 3, :required => true, :disabled => 'false')
CustomFieldFooPair.should_receive(:create).with( params1 ).and_return(foo1)
params2 = @field.merge(@pair2).merge('pair_id' => 3, 'required' => true, 'disabled' => 'false')
- foo2 = mock(:id => 5)
+ foo2 = double(:id => 5)
CustomFieldFooPair.should_receive(:create).with( params2 ).and_return(foo2)
CustomFieldPair.create_pair(@params).should == [foo1, foo2]
end
-
+
end
describe "update_pair" do
-
+
before(:each) do
@field = {'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event'}
@pair1 = {'name' => 'pair1'}
@@ -46,9 +46,9 @@ class CustomFieldFooPair
end
it "should update the pair" do
- foo1 = mock(:required => true, :disabled => 'false')
+ foo1 = double(:required => true, :disabled => 'false')
foo1.should_receive(:update_attributes).with( @field.merge(@pair1) )
- foo2 = mock
+ foo2 = double
foo2.should_receive(:update_attributes).with( @field.merge(@pair2).merge('required' => true, 'disabled' => 'false') )
foo1.should_receive(:paired_with).and_return(foo2)
CustomFieldPair.should_receive(:find).with('3').and_return(foo1)
@@ -57,19 +57,19 @@ class CustomFieldFooPair
end
end
-
+
describe "paired_with" do
-
+
before(:each) do
@field1 = CustomFieldDatePair.new(:name => 'cf_event_from')
@field2 = CustomFieldDatePair.new(:name => 'cf_event_to')
end
-
+
it "should return the 2nd field" do
@field1.should_receive(:pair).and_return(@field2)
@field1.paired_with.should == @field2
end
-
+
it "should return the 1st field" do
@field2.should_receive(:pair).and_return(nil)
@field2.should_receive(:id).and_return(1)
View
8 spec/models/fields/custom_field_spec.rb
@@ -112,16 +112,16 @@
it "should have errors if custom field is required" do
event = CustomField.new(:name => 'cf_event', :required => true)
- foo = mock(:cf_event => nil)
- err = mock(:errors); err.stub(:add)
+ foo = double(:cf_event => nil)
+ err = double(:errors); err.stub(:add)
foo.should_receive(:errors).and_return(err)
event.custom_validator(foo)
end
it "should have errors if custom field is longer than maxlength" do
event = CustomField.new(:name => 'cf_event', :maxlength => 5)
- foo = mock(:cf_event => "This is too long")
- err = mock(:errors); err.stub(:add)
+ foo = double(:cf_event => "This is too long")
+ err = double(:errors); err.stub(:add)
foo.should_receive(:errors).and_return(err)
event.custom_validator(foo)
end
View
2 spec/models/fields/field_spec.rb
@@ -52,7 +52,7 @@
:label => "Availability",
:name => "availability"
)
- object = mock('Object')
+ object = double('Object')
# as | value | expected
[["check_boxes", [1, 2, 3], "1, 2<br />3"],
View
4 spec/models/observers/entity_observer_spec.rb
@@ -11,7 +11,7 @@
let(:assignee) { FactoryGirl.create(:user) }
let(:assigner) { FactoryGirl.create(:user) }
let!(:entity) { FactoryGirl.build(entity_type, :user => assigner, :assignee => assignee) }
- let(:mail) { mock('mail', :deliver => true) }
+ let(:mail) { double('mail', :deliver => true) }
before :each do
PaperTrail.stub(:whodunnit).and_return(assigner)
@@ -40,7 +40,7 @@
let(:assignee) { FactoryGirl.create(:user) }
let(:assigner) { FactoryGirl.create(:user) }
let!(:entity) { FactoryGirl.create(entity_type, :user => FactoryGirl.create(:user)) }
- let(:mail) { mock('mail', :deliver => true) }
+ let(:mail) { double('mail', :deliver => true) }
before :each do
PaperTrail.stub(:whodunnit).and_return(assigner)
View
10 spec/models/users/user_spec.rb
@@ -60,14 +60,14 @@
it "should not destroy the user if she owns #{asset}" do
FactoryGirl.create(asset, :user => @user)
@user.destroy
- lambda { User.find(@user) }.should_not raise_error(ActiveRecord::RecordNotFound)
+ expect { User.find(@user) }.to_not raise_error()
@user.destroyed?.should == false
end
it "should not destroy the user if she has #{asset} assigned" do
FactoryGirl.create(asset, :assignee => @user)
@user.destroy
- lambda { User.find(@user) }.should_not raise_error(ActiveRecord::RecordNotFound)
+ expect { User.find(@user) }.to_not raise_error()
@user.destroyed?.should == false
end
end
@@ -77,20 +77,20 @@
account = FactoryGirl.create(:account, :user => current_user)
FactoryGirl.create(:comment, :user => @user, :commentable => account)
@user.destroy
- lambda { User.find(@user) }.should_not raise_error(ActiveRecord::RecordNotFound)
+ expect { User.find(@user) }.to_not raise_error()
@user.destroyed?.should == false
end
it "should not destroy the current user" do
login
current_user.destroy
- lambda { current_user.reload }.should_not raise_error(ActiveRecord::RecordNotFound)
+ expect { current_user.reload }.to_not raise_error()
current_user.should_not be_destroyed
end
it "should destroy the user" do
@user.destroy
- lambda { User.find(@user) }.should raise_error(ActiveRecord::RecordNotFound)
+ expect { User.find(@user) }.to raise_error(ActiveRecord::RecordNotFound)
@user.should be_destroyed
end
View
152 spec/shared/controllers.rb
@@ -3,103 +3,101 @@
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
-module SharedControllerSpecs
- shared_examples "auto complete" do
- before(:each) do
- @query = "Hello"
- end
+shared_examples "auto complete" do
+ before(:each) do
+ @query = "Hello"
+ end
- it "should do the search and find records that match autocomplete query" do
- post :auto_complete, :auto_complete_query => @query
- assigns[:query].should == @query
- assigns[:auto_complete].should == @auto_complete_matches # Each controller must define it.
- end
+ it "should do the search and find records that match autocomplete query" do
+ post :auto_complete, :auto_complete_query => @query
+ assigns[:query].should == @query
+ assigns[:auto_complete].should == @auto_complete_matches # Each controller must define it.
+ end
- it "should save current autocomplete controller in a session" do
- post :auto_complete, :auto_complete_query => @query
+ it "should save current autocomplete controller in a session" do
+ post :auto_complete, :auto_complete_query => @query
- # We don't save Admin/Users autocomplete controller in a session since Users are not
- # exposed through the Jumpbox.
- unless controller.class.to_s.starts_with?("Admin::")
- session[:auto_complete].should == @controller.controller_name.to_sym
- end
+ # We don't save Admin/Users autocomplete controller in a session since Users are not
+ # exposed through the Jumpbox.
+ unless controller.class.to_s.starts_with?("Admin::")
+ session[:auto_complete].should == @controller.controller_name.to_sym
end
+ end
- it "should render application/_auto_complete template" do
- post :auto_complete, :auto_complete_query => @query
- response.should render_template("application/_auto_complete")
- end
+ it "should render application/_auto_complete template" do
+ post :auto_complete, :auto_complete_query => @query
+ response.should render_template("application/_auto_complete")
end
+end
- shared_examples "attach" do
- it "should attach existing asset to the parent asset of different type" do
- xhr :put, :attach, :id => @model.id, :assets => @attachment.class.name.tableize, :asset_id => @attachment.id
- @model.send(@attachment.class.name.tableize).should include(@attachment)
- assigns[:attachment].should == @attachment
- assigns[:attached].should == [ @attachment ]
- if @model.is_a?(Campaign) && (@attachment.is_a?(Lead) || @attachment.is_a?(Opportunity))
- assigns[:campaign].should == @attachment.reload.campaign
- end
- if @model.is_a?(Account) && @attachment.respond_to?(:account) # Skip Tasks...
- assigns[:account].should == @attachment.reload.account
- end
- response.should render_template("entities/attach")
+shared_examples "attach" do
+ it "should attach existing asset to the parent asset of different type" do
+ xhr :put, :attach, :id => @model.id, :assets => @attachment.class.name.tableize, :asset_id => @attachment.id
+ @model.send(@attachment.class.name.tableize).should include(@attachment)
+ assigns[:attachment].should == @attachment
+ assigns[:attached].should == [ @attachment ]
+ if @model.is_a?(Campaign) && (@attachment.is_a?(Lead) || @attachment.is_a?(Opportunity))
+ assigns[:campaign].should == @attachment.reload.campaign
end
+ if @model.is_a?(Account) && @attachment.respond_to?(:account) # Skip Tasks...
+ assigns[:account].should == @attachment.reload.account
+ end
+ response.should render_template("entities/attach")
+ end
- it "should not attach the asset that is already attached" do
- if @model.is_a?(Campaign) && (@attachment.is_a?(Lead) || @attachment.is_a?(Opportunity))
- @attachment.update_attribute(:campaign_id, @model.id)
- else
- @model.send(@attachment.class.name.tableize) << @attachment
- end
-
- xhr :put, :attach, :id => @model.id, :assets => @attachment.class.name.tableize, :asset_id => @attachment.id
- assigns[:attached].should == nil
- response.should render_template("entities/attach")
+ it "should not attach the asset that is already attached" do
+ if @model.is_a?(Campaign) && (@attachment.is_a?(Lead) || @attachment.is_a?(Opportunity))
+ @attachment.update_attribute(:campaign_id, @model.id)
+ else
+ @model.send(@attachment.class.name.tableize) << @attachment
end
- it "should display flash warning when the model is no longer available" do
- @model.destroy
+ xhr :put, :attach, :id => @model.id, :assets => @attachment.class.name.tableize, :asset_id => @attachment.id
+ assigns[:attached].should == nil
+ response.should render_template("entities/attach")
+ end
- xhr :put, :attach, :id => @model.id, :assets => @attachment.class.name.tableize, :asset_id => @attachment.id
- flash[:warning].should_not == nil
- response.body.should == "window.location.reload();"
- end
- it "should display flash warning when the attachment is no longer available" do
- @attachment.destroy
+ it "should display flash warning when the model is no longer available" do
+ @model.destroy
- xhr :put, :attach, :id => @model.id, :assets => @attachment.class.name.tableize, :asset_id => @attachment.id
- flash[:warning].should_not == nil
- response.body.should == "window.location.reload();"
- end
+ xhr :put, :attach, :id => @model.id, :assets => @attachment.class.name.tableize, :asset_id => @attachment.id
+ flash[:warning].should_not == nil
+ response.body.should == "window.location.reload();"
end
+ it "should display flash warning when the attachment is no longer available" do
+ @attachment.destroy
- shared_examples "discard" do
- it "should discard the attachment without deleting it" do
- xhr :post, :discard, :id => @model.id, :attachment => @attachment.class.name, :attachment_id => @attachment.id
- assigns[:attachment].should == @attachment.reload # The attachment should still exist.
- @model.reload.send("#{@attachment.class.name.tableize}").should == [] # But no longer associated with the model.
- assigns[:account].should == @model if @model.is_a?(Account)
- assigns[:campaign].should == @model if @model.is_a?(Campaign)
+ xhr :put, :attach, :id => @model.id, :assets => @attachment.class.name.tableize, :asset_id => @attachment.id
+ flash[:warning].should_not == nil
+ response.body.should == "window.location.reload();"
+ end
+end
- response.should render_template("entities/discard")
- end
+shared_examples "discard" do
+ it "should discard the attachment without deleting it" do
+ xhr :post, :discard, :id => @model.id, :attachment => @attachment.class.name, :attachment_id => @attachment.id
+ assigns[:attachment].should == @attachment.reload # The attachment should still exist.
+ @model.reload.send("#{@attachment.class.name.tableize}").should == [] # But no longer associated with the model.
+ assigns[:account].should == @model if @model.is_a?(Account)
+ assigns[:campaign].should == @model if @model.is_a?(Campaign)
- it "should display flash warning when the model is no longer available" do
- @model.destroy
+ response.should render_template("entities/discard")
+ end
- xhr :post, :discard, :id => @model.id, :attachment => @attachment.class.name, :attachment_id => @attachment.id
- flash[:warning].should_not == nil
- response.body.should == "window.location.reload();"
- end
+ it "should display flash warning when the model is no longer available" do
+ @model.destroy
- it "should display flash warning when the attachment is no longer available" do
- @attachment.destroy
+ xhr :post, :discard, :id => @model.id, :attachment => @attachment.class.name, :attachment_id => @attachment.id
+ flash[:warning].should_not == nil
+ response.body.should == "window.location.reload();"
+ end
- xhr :post, :discard, :id => @model.id, :attachment => @attachment.class.name, :attachment_id => @attachment.id
- flash[:warning].should_not == nil
- response.body.should == "window.location.reload();"
- end
+ it "should display flash warning when the attachment is no longer available" do
+ @attachment.destroy
+
+ xhr :post, :discard, :id => @model.id, :attachment => @attachment.class.name, :attachment_id => @attachment.id
+ flash[:warning].should_not == nil
+ response.body.should == "window.location.reload();"
end
end
View
4 spec/support/mail_processor_mocks.rb
@@ -5,7 +5,7 @@
#------------------------------------------------------------------------------
module MockIMAP
def mock_imap
- @imap = mock
+ @imap = double
@settings = @crawler.instance_variable_get("@settings")
@settings[:address] = @mock_address
Net::IMAP.stub(:new).with(@settings[:server], @settings[:port], @settings[:ssl]).and_return(@imap)
@@ -24,7 +24,7 @@ def mock_disconnect
end
def mock_message(body)
- @fetch_data = mock
+ @fetch_data = double
@fetch_data.stub(:attr).and_return("RFC822" => body)
@imap.stub(:uid_search).and_return([ :uid ])
@imap.stub(:uid_fetch).and_return([ @fetch_data ])
View
3 zeus.json
@@ -1,5 +1,5 @@
{
- "command": "ruby -rubygems -rzeus/rails -eZeus.go",
+ "command": "ruby -rubygems -r./custom_plan -eZeus.go",
"plan": {
"boot": {
@@ -10,6 +10,7 @@
"console": ["c"],
"server": ["s"],
"generate": ["g"],
+ "destroy": ["d"],
"dbconsole": []
},
"test_environment": {

0 comments on commit 229d713

Please sign in to comment.