27 lines
976 B
Ruby
27 lines
976 B
Ruby
require 'spec_helper'
|
|
|
|
describe NewSupplier do
|
|
let(:new_supplier_params){ {supplier_name: "New suppy", email: 'suppy@example.com', password: 'admin123', password_confirmation: 'admin123'} }
|
|
subject { described_class.new new_supplier_params }
|
|
it { should_not be_persisted }
|
|
|
|
it 'sets the name of the new employee to the email prefix' do
|
|
subject.save
|
|
subject.employee.name.should eq 'suppy'
|
|
end
|
|
|
|
it "does not save anything when the password_confirmation is wrong" do
|
|
new_supplier_params[:password_confirmation] = "something$else"
|
|
subject.save.should be false
|
|
subject.errors[:password_confirmation].should be_present
|
|
end
|
|
|
|
# This is tested with acceptance tests since part of this logic is inside the controller
|
|
xit "does not create a supplier when the name is already taken" do
|
|
create :supplier, name: 'New suppy'
|
|
expect{ subject.save }.not_to change{ Supplier.count }
|
|
subject.errors[:supplier_name].should be_present
|
|
end
|
|
|
|
end
|