Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
social networks controller refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
PanfilovDenis committed Mar 5, 2013
1 parent 1afd89d commit 45168b0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Web::SocialNetworkController < Web::ApplicationController
class Web::SocialNetworksController < Web::ApplicationController

def authorization
authorization = Authorization.find_by_provider_and_uid(auth_hash[:provider], auth_hash[:uid])
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/web/social_network_helper.rb

This file was deleted.

2 changes: 2 additions & 0 deletions app/helpers/web/social_networks_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Web::SocialNetworksHelper
end
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
mount Ckeditor::Engine => '/ckeditor'

# omniauth-facebook
get '/auth/facebook/callback' => 'web/social_network#authorization'
get '/auth/facebook/failure' => 'web/social_network#failure'
get '/auth/facebook/callback' => 'web/social_networks#authorization'
get '/auth/facebook/failure' => 'web/social_networks#failure'

namespace :api do
resources :companies
Expand All @@ -34,7 +34,7 @@
end
end

resource :social_network, :only => [] do
resource :social_networks, :only => [] do
get :authorization, :on => :member
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'test_helper'

class Web::SocialNetworkControllerTest < ActionController::TestCase
class Web::SocialNetworksControllerTest < ActionController::TestCase

setup do
@auth_hash = generate(:facebook_auth_hash)
Expand All @@ -15,9 +15,9 @@ class Web::SocialNetworkControllerTest < ActionController::TestCase
request.env['omniauth.auth'] = @auth_hash
get :authorization

assert_response :redirect
assert signed_in?
assert_equal current_user, @user
assert_response :redirect
end

test "should get authorization with facebook on existing user" do
Expand All @@ -27,19 +27,19 @@ class Web::SocialNetworkControllerTest < ActionController::TestCase
request.env['omniauth.auth'] = @auth_hash
get :authorization

assert_response :redirect
@user.reload
assert @user.active?
assert signed_in?
assert current_user.authorizations
assert_response :redirect
assert !current_user.authorizations.blank?
end

test "should get authorization with facebook on new user" do
request.env['omniauth.auth'] = @auth_hash
get :authorization

assert session_auth_hash
assert_response :redirect
assert session_auth_hash
end

test "should get failure" do
Expand Down
4 changes: 0 additions & 4 deletions test/unit/helpers/web/social_network_helper_test.rb

This file was deleted.

4 changes: 4 additions & 0 deletions test/unit/helpers/web/social_networks_helper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'test_helper'

class Web::SocialNetworksHelperTest < ActionView::TestCase
end

0 comments on commit 45168b0

Please sign in to comment.