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"
|
||||
|
|
@ -5,4 +5,26 @@ end
|
|||
|
||||
When /^I click on my name$/ do
|
||||
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.orm = "mongo_mapper"
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
describe '#create' do
|
||||
|
|
@ -22,7 +49,7 @@ describe RequestsController do
|
|||
)
|
||||
response.should redirect_to aspects_manage_path
|
||||
end
|
||||
|
||||
|
||||
it "flashes and redirects when requesting an invalid identity" do
|
||||
put(:create, {
|
||||
:destination_handle => "not_a_@valid_email",
|
||||
|
|
@ -32,7 +59,7 @@ describe RequestsController do
|
|||
flash[:error].should_not be_blank
|
||||
response.should redirect_to aspects_manage_path
|
||||
end
|
||||
|
||||
|
||||
it "flashes and redirects when requesting an invalid identity with a port number" do
|
||||
put(:create, {
|
||||
:destination_handle => "johndoe@email.com:3000",
|
||||
|
|
@ -42,7 +69,7 @@ describe RequestsController do
|
|||
flash[:error].should_not be_blank
|
||||
response.should redirect_to aspects_manage_path
|
||||
end
|
||||
|
||||
|
||||
it "redirects when requesting an identity from an invalid server" do
|
||||
stub_request(:get, /notadiasporaserver\.com/).to_raise(Errno::ETIMEDOUT)
|
||||
put(:create, {
|
||||
|
|
@ -52,7 +79,7 @@ describe RequestsController do
|
|||
)
|
||||
response.should redirect_to aspects_manage_path
|
||||
end
|
||||
|
||||
|
||||
it 'should redirect to the page which you called it from ' do
|
||||
pending "This controller should probably redirect to :back"
|
||||
put(:create, {
|
||||
|
|
|
|||
1770
spec/fixtures/users.yaml
vendored
1770
spec/fixtures/users.yaml
vendored
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue