fbuser 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/fbuser/application.js +13 -0
- data/app/assets/javascripts/fbuser/authentication.js +2 -0
- data/app/assets/stylesheets/fbuser/application.css +15 -0
- data/app/assets/stylesheets/fbuser/authentication.css +4 -0
- data/app/controllers/fbuser/api/v1/application_controller.rb +5 -0
- data/app/controllers/fbuser/api/v1/authentication_controller.rb +56 -0
- data/app/controllers/fbuser/api/v1/users_controller.rb +100 -0
- data/app/controllers/fbuser/application_controller.rb +4 -0
- data/app/facebook/fbuser/facebook.rb +50 -0
- data/app/helpers/fbuser/application_helper.rb +4 -0
- data/app/helpers/fbuser/authentication_helper.rb +4 -0
- data/app/models/fbuser/user.rb +4 -0
- data/app/models/fbuser/v1/user.rb +32 -0
- data/app/serializers/fbuser/v1/user_serializer.rb +41 -0
- data/app/views/layouts/fbuser/default/application.html.erb +14 -0
- data/config/routes.rb +27 -0
- data/db/migrate/20141026184428_create_fbuser_users.rb +11 -0
- data/lib/fbuser.rb +4 -0
- data/lib/fbuser/engine.rb +5 -0
- data/lib/fbuser/version.rb +3 -0
- data/lib/generators/fbuser/admin/USAGE +8 -0
- data/lib/generators/fbuser/admin/admin_generator.rb +16 -0
- data/lib/generators/fbuser/admin/templates/active_admin.rb +84 -0
- data/lib/generators/fbuser/all/USAGE +8 -0
- data/lib/generators/fbuser/all/all_generator.rb +17 -0
- data/lib/generators/fbuser/authorizations/USAGE +8 -0
- data/lib/generators/fbuser/authorizations/authorizations_generator.rb +19 -0
- data/lib/generators/fbuser/authorizations/templates/user.rb +66 -0
- data/lib/generators/fbuser/tests/USAGE +8 -0
- data/lib/generators/fbuser/tests/templates/authentication_requests.rb +48 -0
- data/lib/generators/fbuser/tests/templates/authentication_routing.rb +20 -0
- data/lib/generators/fbuser/tests/templates/fbuser_user_1_factory.rb +18 -0
- data/lib/generators/fbuser/tests/templates/model_user_spec.rb +53 -0
- data/lib/generators/fbuser/tests/templates/requests_user_spec.rb +138 -0
- data/lib/generators/fbuser/tests/templates/routing_user_spec.rb +47 -0
- data/lib/generators/fbuser/tests/tests_generator.rb +21 -0
- data/lib/tasks/fbuser_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +78 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fbuser_test.rb +7 -0
- data/test/fixtures/fbuser/users.yml +9 -0
- data/test/helpers/fbuser/authentication_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/lib/generators/fbuser/admin_generator_test.rb +16 -0
- data/test/lib/generators/fbuser/all_generator_test.rb +16 -0
- data/test/lib/generators/fbuser/authorizations_generator_test.rb +16 -0
- data/test/lib/generators/fbuser/tests_generator_test.rb +16 -0
- data/test/models/fbuser/user_test.rb +9 -0
- data/test/test_helper.rb +15 -0
- metadata +281 -0
data/lib/fbuser.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fbuser
|
2
|
+
class AdminGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def sprint
|
6
|
+
make_admin
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def make_admin
|
12
|
+
template "active_admin.rb", "app/admin/fbuser_user.rb"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
ActiveAdmin.register Fbuser::User do
|
2
|
+
|
3
|
+
menu :label => "FBUsers"
|
4
|
+
config.per_page = 30
|
5
|
+
|
6
|
+
=begin
|
7
|
+
batch_action :flag do |selection|
|
8
|
+
Fbuser::User.find(selection).each { |p| p.flag! }
|
9
|
+
redirect_to collection_path, :notice => "FBUsers flagged!"
|
10
|
+
end
|
11
|
+
=end
|
12
|
+
|
13
|
+
form do |f|
|
14
|
+
f.semantic_errors # shows errors on :base
|
15
|
+
#f.inputs # builds an input field for every attribute
|
16
|
+
f.inputs do
|
17
|
+
f.input :id
|
18
|
+
f.input :username
|
19
|
+
f.input :fb_user_id
|
20
|
+
f.input :updated_at
|
21
|
+
f.input :created_at
|
22
|
+
end
|
23
|
+
f.actions # adds the 'Submit' and 'Cancel' buttons
|
24
|
+
end
|
25
|
+
|
26
|
+
controller do
|
27
|
+
def create
|
28
|
+
@user = ::Fbuser::V1::User.new(user_params)
|
29
|
+
if @user.save
|
30
|
+
flash[:notice] = "Created Successfully!"
|
31
|
+
redirect_to resource_path @user
|
32
|
+
else
|
33
|
+
flash[:notice] = "#{@user.errors.full_messages}"
|
34
|
+
redirect_to new_resource_path @user
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
@user = ::Fbuser::V1::User.find(params[:id])
|
40
|
+
if @user.update(user_params)
|
41
|
+
flash[:notice] = "Updated Successfully!"
|
42
|
+
redirect_to resource_path @user
|
43
|
+
else
|
44
|
+
flash.now[:notice] = "#{@user.errors.full_messages}"
|
45
|
+
render :edit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def destroy
|
50
|
+
@user = ::Fbuser::V1::User.find(params[:id])
|
51
|
+
@user.destroy
|
52
|
+
flash.now[:notice] = "Deleted Successfully!"
|
53
|
+
render :index
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def user_params
|
59
|
+
params.require(:user).permit(:username,:fb_user_id)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
index do
|
64
|
+
selectable_column
|
65
|
+
column :id
|
66
|
+
column :username
|
67
|
+
column :fb_user_id
|
68
|
+
column :updated_at
|
69
|
+
column :created_at
|
70
|
+
actions
|
71
|
+
end
|
72
|
+
|
73
|
+
show do
|
74
|
+
attributes_table do
|
75
|
+
row :id
|
76
|
+
row :username
|
77
|
+
row :fb_user_id
|
78
|
+
row :updated_at
|
79
|
+
row :created_at
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Fbuser
|
2
|
+
class AllGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def sprint
|
6
|
+
run_all_generators
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def run_all_generators
|
12
|
+
run "rails g fbuser:tests"
|
13
|
+
run "rails g fbuser:authorizations"
|
14
|
+
run "rails g fbuser:admin"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fbuser
|
2
|
+
class AuthorizationsGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def sprint
|
6
|
+
copy_authorization_files_over
|
7
|
+
prepend_file 'gems/authorization/lib/authorization.rb', "require \'authorization/fbuser/v1/user\'\n"
|
8
|
+
#prepend_file 'gems/authorization/lib/authorization.rb', "require \'authorization/people/v1/authentication\'\n"
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def copy_authorization_files_over
|
14
|
+
template "user.rb", "gems/authorization/lib/authorization/fbuser/v1/user.rb"
|
15
|
+
#template "authentication_authorization.rb", "gems/authorization/lib/authorization/people/v1/authentication.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Authorization
|
2
|
+
module Fbuser
|
3
|
+
module V1
|
4
|
+
module User
|
5
|
+
|
6
|
+
#Used in the controller
|
7
|
+
|
8
|
+
def self.index?(tokenUser)
|
9
|
+
return true
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.show?(user,tokenUser)
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.create?(user_params,tokenUser)
|
17
|
+
return true
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.update?(user,user_params,tokenUser)
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.destroy?(user,tokenUser)
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
|
28
|
+
#Used in the serializer
|
29
|
+
|
30
|
+
def self.include_id?(current_user,user_object,options)
|
31
|
+
action = options[:url_options][:_recall][:action]
|
32
|
+
controller = options[:url_options][:_recall][:controller]
|
33
|
+
return true
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def self.include_username?(current_user,user_object,options)
|
38
|
+
action = options[:url_options][:_recall][:action]
|
39
|
+
controller = options[:url_options][:_recall][:controller]
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.include_fb_user_id?(current_user,user_object,options)
|
44
|
+
action = options[:url_options][:_recall][:action]
|
45
|
+
controller = options[:url_options][:_recall][:controller]
|
46
|
+
return true
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.include_created_at?(current_user,user_object,options)
|
50
|
+
action = options[:url_options][:_recall][:action]
|
51
|
+
controller = options[:url_options][:_recall][:controller]
|
52
|
+
return true
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.include_updated_at?(current_user,user_object,options)
|
56
|
+
action = options[:url_options][:_recall][:action]
|
57
|
+
controller = options[:url_options][:_recall][:controller]
|
58
|
+
return true
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
#-#-#-#-#Collection Routes#-#-#-#-#
|
4
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
5
|
+
describe "Login" do
|
6
|
+
before(:example) do
|
7
|
+
@token = "facebook_test_user_token"
|
8
|
+
@header = {::Settings.main_api_header => ::Settings.main_api_key}
|
9
|
+
end
|
10
|
+
it "checks the response of a user" do
|
11
|
+
hash = {token: @token}
|
12
|
+
post '/api/1/authentication/login', hash, @header
|
13
|
+
#pp json["api_token"]
|
14
|
+
post '/api/1/authentication/login', hash, @header
|
15
|
+
#pp json["api_token"]
|
16
|
+
end
|
17
|
+
# post /api/1/authentication/login
|
18
|
+
it "registers a user" do
|
19
|
+
|
20
|
+
end
|
21
|
+
# post /api/1/authentication/login
|
22
|
+
it "logs in a user" do
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "Logout" do
|
28
|
+
before(:example) do
|
29
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
30
|
+
token = @user.tokens[0].auth_token
|
31
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
32
|
+
end
|
33
|
+
# post /api/1/authentication/logout
|
34
|
+
it "removes a token on logout" do
|
35
|
+
expect(::Arcadex::Token.count).to eq(1)
|
36
|
+
post "api/1/authentication/logout", nil, @header
|
37
|
+
expect(response.status).to eq(200)
|
38
|
+
expect(::Arcadex::Token.count).to eq(0)
|
39
|
+
end
|
40
|
+
# post /api/1/authentication/logout
|
41
|
+
it "makes sure a user is logged in to logout" do
|
42
|
+
expect(::Arcadex::Token.count).to eq(1)
|
43
|
+
post "api/1/authentication/logout", nil, {::Settings.main_api_header => ::Settings.main_api_key}
|
44
|
+
expect(response.status).to eq(401)
|
45
|
+
expect(::Arcadex::Token.count).to eq(1)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
#The login routes
|
4
|
+
RSpec.describe "Users login process routing", :type => :routing do
|
5
|
+
routes { Fbuser::Engine.routes }
|
6
|
+
|
7
|
+
it "routes to login" do
|
8
|
+
expect(:post => "/api/1/authentication/login").to route_to(
|
9
|
+
:controller => "fbuser/api/v1/authentication",
|
10
|
+
:action => "login"
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "routes to logout" do
|
15
|
+
expect(:post => "/api/1/authentication/logout").to route_to(
|
16
|
+
:controller => "fbuser/api/v1/authentication",
|
17
|
+
:action => "logout"
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
sequence :username do |n|
|
3
|
+
"username#{n}"
|
4
|
+
end
|
5
|
+
sequence :fb_user_id do |n|
|
6
|
+
n
|
7
|
+
end
|
8
|
+
#sequence :name do |n|
|
9
|
+
# "name#{n}"
|
10
|
+
#end
|
11
|
+
factory :fbuser_user_1, class: ::Fbuser::V1::User do
|
12
|
+
|
13
|
+
username
|
14
|
+
fb_user_id
|
15
|
+
#name
|
16
|
+
#attr "Default value"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
|
4
|
+
RSpec.describe ::Fbuser::V1::User, '.username', :type => :model do
|
5
|
+
describe "Attributes" do
|
6
|
+
it "does not save when attribute is nil" do
|
7
|
+
#user = FactoryGirl.build(:fbuser_user_1, :username => nil)
|
8
|
+
#expect(user.save).to equal(false)
|
9
|
+
end
|
10
|
+
it "does not save when username:string is ..." do
|
11
|
+
#expect(user.save).to equal(false)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.describe ::Fbuser::V1::User, '.fb_user_id', :type => :model do
|
17
|
+
describe "Attributes" do
|
18
|
+
it "does not save when attribute is nil" do
|
19
|
+
user = FactoryGirl.build(:fbuser_user_1, :fb_user_id => nil)
|
20
|
+
expect(user.save).to equal(false)
|
21
|
+
end
|
22
|
+
it "does not save when fb_user_id is already taken" do
|
23
|
+
user = FactoryGirl.build(:fbuser_user_1, :fb_user_id => 1)
|
24
|
+
expect(user.save).to equal(true)
|
25
|
+
begin
|
26
|
+
user = FactoryGirl.build(:fbuser_user_1, :fb_user_id => 1)
|
27
|
+
expect(user.save).to equal(false)
|
28
|
+
rescue
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec.describe ::Fbuser::V1::User, :type => :model do
|
35
|
+
describe "Dependencies" do
|
36
|
+
before(:example) do
|
37
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
38
|
+
end
|
39
|
+
it "deletes ... when deleted" do
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
RSpec.describe ::Fbuser::V1::User, :type => :model do
|
45
|
+
describe "Callbacks" do
|
46
|
+
before(:example) do
|
47
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
48
|
+
end
|
49
|
+
it "creates a token on creation" do
|
50
|
+
expect(@user.tokens[0]).to_not equal(nil)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
#-#-#-#-#REST#-#-#-#-#
|
4
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
5
|
+
describe "Index" do
|
6
|
+
before(:example) do
|
7
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
8
|
+
token = @user.tokens[0].auth_token
|
9
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
10
|
+
end
|
11
|
+
# get /api/1/users
|
12
|
+
it "Gets all of the users" do
|
13
|
+
FactoryGirl.create_list(:fbuser_user_1, 10)
|
14
|
+
get 'api/1/users', nil, @header
|
15
|
+
expect(response.status).to eq(200) #ok
|
16
|
+
expect(::Fbuser::V1::User.count).to eq(11)
|
17
|
+
expect(json["users"].length).to eq(11)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
22
|
+
describe "Show" do
|
23
|
+
before(:example) do
|
24
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
25
|
+
token = @user.tokens[0].auth_token
|
26
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
27
|
+
end
|
28
|
+
# get /api/1/users/1
|
29
|
+
it "Gets a user by id" do
|
30
|
+
user = FactoryGirl.create(:fbuser_user_1)
|
31
|
+
get "api/1/users/#{user.id}", nil, @header
|
32
|
+
expect(response.status).to eq(200) #ok
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
=begin
|
37
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
38
|
+
describe "Create" do
|
39
|
+
before(:example) do
|
40
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
41
|
+
token = @user.tokens[0].auth_token
|
42
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
43
|
+
end
|
44
|
+
# post /api/1/users
|
45
|
+
it "Creates user" do
|
46
|
+
attrs = FactoryGirl.attributes_for(:fbuser_user_1)
|
47
|
+
#attrs[:column] = "LaunchU"
|
48
|
+
hash = {"user" => attrs}
|
49
|
+
post 'api/1/users', hash, @header
|
50
|
+
expect(response.status).to eq(200) #ok
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
=end
|
55
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
56
|
+
describe "Update" do
|
57
|
+
before(:example) do
|
58
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
59
|
+
token = @user.tokens[0].auth_token
|
60
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
61
|
+
end
|
62
|
+
# patch/put /api/1/users/1
|
63
|
+
it "Updates user" do
|
64
|
+
#Create the user through the api
|
65
|
+
attrs = FactoryGirl.attributes_for(:fbuser_user_1)
|
66
|
+
#attrs[:column] = "LaunchU"
|
67
|
+
user = FactoryGirl.create(:fbuser_user_1)
|
68
|
+
hash = {"user" => attrs}
|
69
|
+
put "api/1/users/#{user.id}", hash, @header
|
70
|
+
expect(response.status).to eq(200) #ok
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
75
|
+
describe "Destroy" do
|
76
|
+
before(:example) do
|
77
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
78
|
+
token = @user.tokens[0].auth_token
|
79
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
80
|
+
end
|
81
|
+
# delete /api/1/users/1
|
82
|
+
it "Deletes user" do
|
83
|
+
#Create the user through the api
|
84
|
+
attrs = FactoryGirl.attributes_for(:fbuser_user_1)
|
85
|
+
#attrs[:column] = "LaunchU"
|
86
|
+
user = FactoryGirl.create(:fbuser_user_1)
|
87
|
+
expect(Fbuser::V1::User.count).to eq(2)
|
88
|
+
#Now delete the user through the api
|
89
|
+
delete "api/1/users/#{user.id}", nil, @header
|
90
|
+
expect(json).to eq({})
|
91
|
+
expect(response.status).to eq(200) #ok
|
92
|
+
expect(Fbuser::V1::User.count).to eq(1)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
#-#-#-#-#Collection Routes#-#-#-#-#
|
97
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
98
|
+
describe "Collection Routes" do
|
99
|
+
before(:example) do
|
100
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
101
|
+
token = @user.tokens[0].auth_token
|
102
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
103
|
+
end
|
104
|
+
# get /api/1/collection
|
105
|
+
it "checks response of a collection route" do
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
#-#-#-#-#Serialization#-#-#-#-#
|
111
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
112
|
+
describe "Serialization" do
|
113
|
+
before(:example) do
|
114
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
115
|
+
token = @user.tokens[0].auth_token
|
116
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
117
|
+
end
|
118
|
+
it "checks the index json sent back" do
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
#-#-#-#-#Errors#-#-#-#-#
|
124
|
+
RSpec.describe ::Fbuser::V1::User, :type => :request do
|
125
|
+
describe "Errors" do
|
126
|
+
before(:example) do
|
127
|
+
@user = FactoryGirl.create(:fbuser_user_1)
|
128
|
+
token = @user.tokens[0].auth_token
|
129
|
+
@header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
|
130
|
+
end
|
131
|
+
# get /api/1/users/1
|
132
|
+
it "checks for a 404" do
|
133
|
+
user = FactoryGirl.create(:fbuser_user_1)
|
134
|
+
get "api/1/users/#{user.id + 1}", nil, @header
|
135
|
+
expect(response.status).to eq(404) #ok
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|