Skip to content

Commit c980bb5

Browse files
authored
Add devise-token-auth and create test dummy (#1)
1 parent 27b8d31 commit c980bb5

47 files changed

Lines changed: 717 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99

1010
# rspec failure tracking
1111
.rspec_status
12+
/spec/dummy/log/
13+
/spec/dummy/tmp/
14+
/Gemfile.lock
15+
/*.sqlite3
16+
/spec/dummy/db/development.sqlite3
17+
/spec/dummy/db/test.sqlite3

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
source "https://rubygems.org"
22

33
gemspec
4+
5+
gem 'bootsnap', require: false
6+
gem 'listen'

graphql_devise.gemspec

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
66
spec.name = 'graphql_devise'
77
spec.version = GraphqlDevise::VERSION
88
spec.authors = ['Mario Celi', 'David Revelo']
9-
spec.email = ['mcelicalderon@gmail.com']
9+
spec.email = ['mcelicalderon@gmail.com', 'david.revelo.uio@gmail.com']
1010

1111
spec.summary = 'GraphQL queries and mutations on top of devise_token_auth'
1212
spec.description = 'GraphQL queries and mutations on top of devise_token_auth'
@@ -15,15 +15,18 @@ Gem::Specification.new do |spec|
1515

1616
spec.metadata['homepage_uri'] = spec.homepage
1717
spec.metadata['source_code_uri'] = 'https://github.com/graphql-device/graphql_devise'
18-
1918
spec.files = Dir.chdir(File.expand_path(__dir__)) do
2019
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
2120
end
2221
spec.bindir = 'exe'
2322
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2423
spec.require_paths = ['lib']
24+
spec.test_files = Dir["spec/**/*"]
25+
26+
spec.add_dependency 'devise_token_auth'
2527

2628
spec.add_development_dependency 'bundler', '~> 2.0'
2729
spec.add_development_dependency 'rake', '~> 10.0'
28-
spec.add_development_dependency 'rspec', '~> 3.0'
30+
spec.add_development_dependency 'rspec-rails'
31+
spec.add_development_dependency 'sqlite3'
2932
end

lib/graphql_devise.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
require 'devise_token_auth'
12
require 'graphql_devise/version'
3+
require 'graphql_devise/concerns/models/testable'
24

35
module GraphqlDevise
46
class Error < StandardError; end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module GraphqlDevise
2+
module Concerns
3+
module Models
4+
module Testable
5+
def test
6+
'This is a test'
7+
end
8+
end
9+
end
10+
end
11+
end
12+

spec/dummy/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# README
2+
3+
This README would normally document whatever steps are necessary to get the
4+
application up and running.
5+
6+
Things you may want to cover:
7+
8+
* Ruby version
9+
10+
* System dependencies
11+
12+
* Configuration
13+
14+
* Database creation
15+
16+
* Database initialization
17+
18+
* How to run the test suite
19+
20+
* Services (job queues, cache servers, search engines, etc.)
21+
22+
* Deployment instructions
23+
24+
* ...

spec/dummy/Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require_relative 'config/application'
5+
6+
Rails.application.load_tasks
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationController < ActionController::API
2+
end
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
class UsersController < ApplicationController
2+
before_action :set_user, only: [:show, :update, :destroy]
3+
4+
# GET /users
5+
def index
6+
@users = User.all
7+
8+
render json: @users
9+
end
10+
11+
# GET /users/1
12+
def show
13+
render json: @user
14+
end
15+
16+
# POST /users
17+
def create
18+
@user = User.new(user_params)
19+
20+
if @user.save
21+
render json: @user, status: :created, location: @user
22+
else
23+
render json: @user.errors, status: :unprocessable_entity
24+
end
25+
end
26+
27+
# PATCH/PUT /users/1
28+
def update
29+
if @user.update(user_params)
30+
render json: @user
31+
else
32+
render json: @user.errors, status: :unprocessable_entity
33+
end
34+
end
35+
36+
# DELETE /users/1
37+
def destroy
38+
@user.destroy
39+
end
40+
41+
private
42+
# Use callbacks to share common setup or constraints between actions.
43+
def set_user
44+
@user = User.find(params[:id])
45+
end
46+
47+
# Only allow a trusted parameter "white list" through.
48+
def user_params
49+
params.require(:user).permit(:email, :name)
50+
end
51+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationJob < ActiveJob::Base
2+
end

0 commit comments

Comments
 (0)