backup commit smart signup form

This commit is contained in:
2015-10-21 18:29:24 +02:00
parent ecf6a3d85a
commit e69b783eb0
7 changed files with 54 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
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
it "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