diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4c2dde8..6f54c8a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,8 +3,11 @@
-
+
+
+
+
@@ -36,101 +39,48 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -155,7 +105,6 @@
-
@@ -186,11 +135,13 @@
-
-
-
+
+
+
+
+
@@ -220,9 +171,6 @@
-
-
-
@@ -241,10 +189,18 @@
+
+
+
+
+
+
+
+
@@ -383,25 +339,26 @@
-
+
+
-
+
-
+
-
+
-
+
@@ -425,19 +382,10 @@
-
-
-
-
-
-
-
-
-
@@ -452,7 +400,6 @@
-
@@ -477,20 +424,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -668,14 +601,6 @@
-
-
-
-
-
-
-
-
@@ -683,14 +608,6 @@
-
-
-
-
-
-
-
-
@@ -702,7 +619,6 @@
-
@@ -710,15 +626,6 @@
-
-
-
-
-
-
-
-
-
@@ -726,7 +633,6 @@
-
@@ -734,7 +640,6 @@
-
@@ -742,7 +647,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -754,40 +682,61 @@
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index e256b7b..c83ad5f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -29,6 +29,7 @@ gem 'rack-cors', :require => 'rack/cors'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
+ gem 'faker'
gem 'rspec-rails', '~> 3.5'
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
@@ -36,7 +37,6 @@ end
group :test do
gem 'factory_girl_rails', '~> 4.0'
gem 'shoulda-matchers', '~> 3.1'
- gem 'faker'
gem 'database_cleaner'
end
diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb
index 931e2ce..1c0207a 100644
--- a/app/controllers/articles_controller.rb
+++ b/app/controllers/articles_controller.rb
@@ -4,7 +4,7 @@ class ArticlesController < ApplicationController
# GET /articles
def index
- @article = Article.all.to_json(include: :user)
+ @article = Article.order(:created_at).reverse.to_json(include: :user)
json_response(@article)
end
@@ -16,7 +16,7 @@ class ArticlesController < ApplicationController
# GET /articles/:id
def show
- json_response(@article)
+ json_response(@article.to_json(include: :user))
end
# PUT /articles/:id
@@ -39,7 +39,7 @@ class ArticlesController < ApplicationController
end
def set_article
- @article = Article.find(params[:id]).to_json(include: :user)
+ @article = Article.find(params[:id])
end
end
diff --git a/config/application.rb b/config/application.rb
index 74d1470..bdeb368 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -28,7 +28,7 @@ module VeretoApi
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
- resource '*', :headers => :any, :methods => [:get, :post, :options]
+ resource '*', :headers => :any, :methods => [:get, :post, :options, :patch, :delete]
end
end
diff --git a/config/database.yml b/config/database.yml
index 4de6498..1b594a1 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -23,7 +23,7 @@ development:
# Do not set this db to the same as development or production.
test:
<<: *default
- database: vereto-api-dev
+ database: vereto-api-test
production:
<<: *default
diff --git a/db/seeds.rb b/db/seeds.rb
index 1beea2a..d91fe67 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -5,3 +5,21 @@
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
+30.times do |n|
+ name = Faker::Name.name
+ email = Faker::Internet.email
+ password = "Muffins24"
+ User.create!(name: name,
+ email: email,
+ password: password,
+ password_confirmation: password)
+end
+
+30.times do |n|
+ title = Faker::Lovecraft.tome
+ content = Faker::Lovecraft.paragraphs(5)
+ Article.create!(title: title,
+ post: content.to_s,
+ user_id: 1)
+
+end
\ No newline at end of file