cucumber green in postgres (i think?). touched up aspect spec.

This commit is contained in:
danielgrippi 2011-08-29 15:53:47 -07:00
parent 1198670383
commit bd77560636
3 changed files with 20 additions and 31 deletions

View file

@ -8,7 +8,7 @@ Feature: private messages
Given a user with username "bob"
And a user named "Alice Awesome" with email "alice@alice.alice"
When I sign in as "bob@bob.bob"
And a user with username "bob" is connected with "Alice_Awesome"
And a user with username "bob" is connected with "alice_awesome"
Scenario: send a message
Given I send a message with subject "Greetings" and text "hello, alice!" to "Alice Awesome"

View file

@ -27,11 +27,12 @@ end
Given /^a user named "([^\"]*)" with email "([^\"]*)"$/ do |name, email|
first, last = name.split
username = "#{first}_#{last}" if first
user = Factory(:user, :email => email, :password => 'password', :username => "#{first}_#{last}",
user = Factory.create(:user, :email => email, :password => 'password', :username => "#{first}_#{last}",
:password_confirmation => 'password', :getting_started => false)
user.profile.update_attributes(:first_name => first, :last_name => last) if first
user.aspects.create(:name => "Besties")
user.aspects.create(:name => "Unicorns")
user.profile.update_attributes!(:first_name => first, :last_name => last) if first
user.aspects.create!(:name => "Besties")
user.aspects.create!(:name => "Unicorns")
end
Given /^I have been invited by an admin$/ do

View file

@ -5,29 +5,20 @@
require 'spec_helper'
describe Aspect do
let(:user ) { alice }
let(:connected_person) { Factory.create(:person) }
let(:user2) { eve }
let(:connected_person_2) { Factory.create(:person) }
let(:aspect) {user.aspects.first }
let(:aspect2) {user2.aspects.first }
let(:aspect1) {user.aspects.create(:name => 'cats')}
let(:user3) {Factory.create(:user)}
let(:aspect3) {user3.aspects.create(:name => "lala")}
describe 'creation' do
let!(:aspect){user.aspects.create(:name => 'losers')}
before do
@name = alice.aspects.first.name
end
it 'does not allow duplicate names' do
lambda {
invalid_aspect = user.aspects.create(:name => "losers ")
invalid_aspect = alice.aspects.create(:name => @name)
}.should_not change(Aspect, :count)
end
it 'validates case insensitiveness on names' do
lambda {
invalid_aspect = user.aspects.create(:name => "Losers ")
invalid_aspect = alice.aspects.create(:name => @name.titleize)
}.should_not change(Aspect, :count)
end
@ -37,26 +28,23 @@ describe Aspect do
end
it 'is able to have other users as contacts' do
Contact.create(:user => user, :person => user2.person, :aspects => [aspect])
aspect.contacts.where(:person_id => user.person.id).should be_empty
aspect.contacts.where(:person_id => user2.person.id).should_not be_empty
aspect = alice.aspects.create(:name => 'losers')
Contact.create(:user => alice, :person => eve.person, :aspects => [aspect])
aspect.contacts.where(:person_id => alice.person.id).should be_empty
aspect.contacts.where(:person_id => eve.person.id).should_not be_empty
aspect.contacts.size.should == 1
end
it 'has a contacts_visible? method' do
aspect.contacts_visible?.should be_true
alice.aspects.first.contacts_visible?.should be_true
end
end
describe 'validation' do
it 'has a unique name for one user' do
aspect2 = user.aspects.create(:name => aspect.name)
aspect2.valid?.should be_false
end
it 'has no uniqueness between users' do
aspect = user.aspects.create(:name => "New Aspect")
aspect2 = user2.aspects.create(:name => aspect.name)
it 'has no uniqueness of name between users' do
aspect = alice.aspects.create(:name => "New Aspect")
aspect2 = eve.aspects.create(:name => aspect.name)
aspect2.should be_valid
end
end