cucumber green in postgres (i think?). touched up aspect spec.
This commit is contained in:
parent
1198670383
commit
bd77560636
3 changed files with 20 additions and 31 deletions
|
|
@ -8,7 +8,7 @@ Feature: private messages
|
||||||
Given a user with username "bob"
|
Given a user with username "bob"
|
||||||
And a user named "Alice Awesome" with email "alice@alice.alice"
|
And a user named "Alice Awesome" with email "alice@alice.alice"
|
||||||
When I sign in as "bob@bob.bob"
|
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
|
Scenario: send a message
|
||||||
Given I send a message with subject "Greetings" and text "hello, alice!" to "Alice Awesome"
|
Given I send a message with subject "Greetings" and text "hello, alice!" to "Alice Awesome"
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,12 @@ end
|
||||||
Given /^a user named "([^\"]*)" with email "([^\"]*)"$/ do |name, email|
|
Given /^a user named "([^\"]*)" with email "([^\"]*)"$/ do |name, email|
|
||||||
first, last = name.split
|
first, last = name.split
|
||||||
username = "#{first}_#{last}" if first
|
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)
|
:password_confirmation => 'password', :getting_started => false)
|
||||||
user.profile.update_attributes(:first_name => first, :last_name => last) if first
|
|
||||||
user.aspects.create(:name => "Besties")
|
user.profile.update_attributes!(:first_name => first, :last_name => last) if first
|
||||||
user.aspects.create(:name => "Unicorns")
|
user.aspects.create!(:name => "Besties")
|
||||||
|
user.aspects.create!(:name => "Unicorns")
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^I have been invited by an admin$/ do
|
Given /^I have been invited by an admin$/ do
|
||||||
|
|
|
||||||
|
|
@ -5,29 +5,20 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Aspect do
|
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
|
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
|
it 'does not allow duplicate names' do
|
||||||
lambda {
|
lambda {
|
||||||
invalid_aspect = user.aspects.create(:name => "losers ")
|
invalid_aspect = alice.aspects.create(:name => @name)
|
||||||
}.should_not change(Aspect, :count)
|
}.should_not change(Aspect, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates case insensitiveness on names' do
|
it 'validates case insensitiveness on names' do
|
||||||
lambda {
|
lambda {
|
||||||
invalid_aspect = user.aspects.create(:name => "Losers ")
|
invalid_aspect = alice.aspects.create(:name => @name.titleize)
|
||||||
}.should_not change(Aspect, :count)
|
}.should_not change(Aspect, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -37,26 +28,23 @@ describe Aspect do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is able to have other users as contacts' do
|
it 'is able to have other users as contacts' do
|
||||||
Contact.create(:user => user, :person => user2.person, :aspects => [aspect])
|
aspect = alice.aspects.create(:name => 'losers')
|
||||||
aspect.contacts.where(:person_id => user.person.id).should be_empty
|
|
||||||
aspect.contacts.where(:person_id => user2.person.id).should_not be_empty
|
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
|
aspect.contacts.size.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a contacts_visible? method' do
|
it 'has a contacts_visible? method' do
|
||||||
aspect.contacts_visible?.should be_true
|
alice.aspects.first.contacts_visible?.should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'validation' do
|
describe 'validation' do
|
||||||
it 'has a unique name for one user' do
|
it 'has no uniqueness of name between users' do
|
||||||
aspect2 = user.aspects.create(:name => aspect.name)
|
aspect = alice.aspects.create(:name => "New Aspect")
|
||||||
aspect2.valid?.should be_false
|
aspect2 = eve.aspects.create(:name => aspect.name)
|
||||||
end
|
|
||||||
|
|
||||||
it 'has no uniqueness between users' do
|
|
||||||
aspect = user.aspects.create(:name => "New Aspect")
|
|
||||||
aspect2 = user2.aspects.create(:name => aspect.name)
|
|
||||||
aspect2.should be_valid
|
aspect2.should be_valid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue