Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec_helper.rb'
- describe Companies::RegistrationsController do
- render_views
- before do
- request.env["devise.mapping"] = Devise.mappings[:company]
- @sub_category1 = Factory 'company/sub_category'
- @sub_category2 = Factory 'company/sub_category'
- end
- describe "GET 'new'" do
- it "should get new" do
- get :new
- response.should be_success
- end
- end
- describe "POST 'create'" do
- it "should be redirect" do
- data = Factory.build(:company).attributes.symbolize_keys
- data.delete(:sub_categories)
- data[:address_attributes] = Factory.build('company/address', :company => nil).attributes.symbolize_keys
- data[:sub_category_ids] = []
- data[:sub_category_ids] << @sub_category1.id
- data[:sub_category_ids] << @sub_category2.id
- data[:password] = 'password'
- data[:password_confirmation] = 'password'
- post :create, :company => data
- response.should be_redirect
- company = Company.find_by_email(data[:email])
- company.should_not be_nil
- company.address.should be
- company.address.company.should == company
- company.sub_categories.size.should == 2
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement