Skip to content
Extraits de code Groupes Projets
Valider 830a43ec rédigé par Sarah Mei's avatar Sarah Mei
Parcourir les fichiers

Add destroy specs for RequestsController.

Cucumber feature for contact requests.
parent 2ad74d39
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
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 ...@@ -5,4 +5,26 @@ 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
\ No newline at end of file
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 ...@@ -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
\ No newline at end of file
...@@ -10,7 +10,34 @@ describe RequestsController do ...@@ -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
...@@ -22,7 +49,7 @@ describe RequestsController do ...@@ -22,7 +49,7 @@ describe RequestsController do
) )
response.should redirect_to aspects_manage_path response.should redirect_to aspects_manage_path
end end
it "flashes and redirects when requesting an invalid identity" do it "flashes and redirects when requesting an invalid identity" do
put(:create, { put(:create, {
:destination_handle => "not_a_@valid_email", :destination_handle => "not_a_@valid_email",
...@@ -32,7 +59,7 @@ describe RequestsController do ...@@ -32,7 +59,7 @@ describe RequestsController do
flash[:error].should_not be_blank flash[:error].should_not be_blank
response.should redirect_to aspects_manage_path response.should redirect_to aspects_manage_path
end end
it "flashes and redirects when requesting an invalid identity with a port number" do it "flashes and redirects when requesting an invalid identity with a port number" do
put(:create, { put(:create, {
:destination_handle => "johndoe@email.com:3000", :destination_handle => "johndoe@email.com:3000",
...@@ -42,7 +69,7 @@ describe RequestsController do ...@@ -42,7 +69,7 @@ describe RequestsController do
flash[:error].should_not be_blank flash[:error].should_not be_blank
response.should redirect_to aspects_manage_path response.should redirect_to aspects_manage_path
end end
it "redirects when requesting an identity from an invalid server" do it "redirects when requesting an identity from an invalid server" do
stub_request(:get, /notadiasporaserver\.com/).to_raise(Errno::ETIMEDOUT) stub_request(:get, /notadiasporaserver\.com/).to_raise(Errno::ETIMEDOUT)
put(:create, { put(:create, {
...@@ -52,7 +79,7 @@ describe RequestsController do ...@@ -52,7 +79,7 @@ describe RequestsController do
) )
response.should redirect_to aspects_manage_path response.should redirect_to aspects_manage_path
end end
it 'should redirect to the page which you called it from ' do it 'should redirect to the page which you called it from ' do
pending "This controller should probably redirect to :back" pending "This controller should probably redirect to :back"
put(:create, { put(:create, {
......
Ce diff est replié.
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter