Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2011
1,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.16 KB | None | 0 0
  1. require 'spec_helper.rb'
  2.  
  3. describe Companies::RegistrationsController do
  4.   render_views
  5.  
  6.   before do
  7.     request.env["devise.mapping"] = Devise.mappings[:company]
  8.     @sub_category1 = Factory 'company/sub_category'
  9.     @sub_category2 = Factory 'company/sub_category'
  10.   end
  11.  
  12.   describe "GET 'new'" do
  13.     it "should get new" do
  14.       get :new
  15.       response.should be_success
  16.     end
  17.   end
  18.  
  19.   describe "POST 'create'" do
  20.     it "should be redirect" do
  21.       data = Factory.build(:company).attributes.symbolize_keys
  22.  
  23.       data.delete(:sub_categories)
  24.       data[:address_attributes] = Factory.build('company/address', :company => nil).attributes.symbolize_keys
  25.       data[:sub_category_ids] = []
  26.       data[:sub_category_ids] << @sub_category1.id
  27.       data[:sub_category_ids] << @sub_category2.id
  28.       data[:password] = 'password'
  29.       data[:password_confirmation] = 'password'
  30.      
  31.       post :create, :company => data
  32.       response.should be_redirect
  33.  
  34.       company = Company.find_by_email(data[:email])
  35.       company.should_not be_nil
  36.       company.address.should be
  37.       company.address.company.should == company
  38.       company.sub_categories.size.should == 2
  39.     end
  40.   end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement