Add destroy specs for RequestsController.
Cucumber feature for contact requests.
This commit is contained in:
parent
2ad74d397c
commit
830a43ec2f
5 changed files with 947 additions and 911 deletions
19
features/manages_contact_requests.feature
Normal file
19
features/manages_contact_requests.feature
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
Feature: managing contact requests
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given I am signed in
|
||||||
|
And I have one contact request
|
||||||
|
|
||||||
|
Scenario: seeing contact requests
|
||||||
|
When I am on the home page
|
||||||
|
Then I should see "Manage (1)" in the header
|
||||||
|
|
||||||
|
@javascript @wip
|
||||||
|
Scenario: accepting a contact request
|
||||||
|
When I am on the home page
|
||||||
|
And I follow "Manage (1)"
|
||||||
|
Then I should see 1 contact request
|
||||||
|
And I should see 0 contacts in "Family"
|
||||||
|
|
||||||
|
When I drag the contact request to the "Family" aspect
|
||||||
|
Then I should see 1 contact in "Family"
|
||||||
|
|
@ -6,3 +6,25 @@ end
|
||||||
When /^I click on my name$/ do
|
When /^I click on my name$/ do
|
||||||
click_link("#{@me.first_name} #{@me.last_name}")
|
click_link("#{@me.first_name} #{@me.last_name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^I have one contact request$/ do
|
||||||
|
other_user = make_user
|
||||||
|
other_user.aspects.create!(:name => "meh")
|
||||||
|
other_user.reload
|
||||||
|
|
||||||
|
other_user.send_contact_request_to(@me.person, other_user.aspects.first)
|
||||||
|
@me.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should see (\d+) contact request(?:s)?$/ do |request_count|
|
||||||
|
pending
|
||||||
|
# person.request.ui-draggable.count.should == request_count - but how do I count things in CSS?
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should see (\d+) contact(?:s)? in "([^"]*)"$/ do |request_count, aspect_name|
|
||||||
|
pending # express the regexp above with the code you wish you had
|
||||||
|
end
|
||||||
|
|
||||||
|
When /^I drag the contact request to the "([^"]*)" aspect$/ do |aspect_name|
|
||||||
|
pending # express the regexp above with the code you wish you had
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -41,3 +41,11 @@ begin
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = :truncation
|
||||||
DatabaseCleaner.orm = "mongo_mapper"
|
DatabaseCleaner.orm = "mongo_mapper"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
||||||
|
include HelperMethods
|
||||||
|
|
||||||
|
Before do
|
||||||
|
UserFixer.regenerate_user_fixtures
|
||||||
|
UserFixer.load_user_fixtures
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,34 @@ describe RequestsController do
|
||||||
@user = make_user
|
@user = make_user
|
||||||
|
|
||||||
sign_in :user, @user
|
sign_in :user, @user
|
||||||
@user.aspects.create(:name => "lame-os")
|
|
||||||
|
@user.aspects.create!(:name => "lame-os")
|
||||||
|
@user.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#destroy' do
|
||||||
|
before do
|
||||||
|
@other_user = make_user
|
||||||
|
@other_user.aspects.create!(:name => "meh")
|
||||||
|
@other_user.reload
|
||||||
|
|
||||||
|
@other_user.send_contact_request_to(@user.person, @other_user.aspects.first)
|
||||||
|
|
||||||
|
@user.reload # so it can find its pending requests.
|
||||||
|
@friend_request = @user.pending_requests.first
|
||||||
|
end
|
||||||
|
describe 'when accepting a contact request' do
|
||||||
|
it "succeeds" do
|
||||||
|
xhr :delete, :destroy, "accept" => "true", "aspect_id" => @user.aspects.first.id.to_s, "id" => @friend_request.id.to_s
|
||||||
|
response.should redirect_to(aspect_path(@user.aspects.first))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe 'when ignoring a contact request' do
|
||||||
|
it "succeeds" do
|
||||||
|
xhr :delete, :destroy, "id" => @friend_request.id.to_s
|
||||||
|
response.should redirect_to(requests_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
|
|
|
||||||
1786
spec/fixtures/users.yaml
vendored
1786
spec/fixtures/users.yaml
vendored
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue