Skip to content

Commit

Permalink
okay nvm not restricting users
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed Dec 2, 2017
1 parent 9f5c3e0 commit d2d28fc
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 22 deletions.
7 changes: 7 additions & 0 deletions .ebextensions/01_files.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
1 change: 1 addition & 0 deletions app/controllers/.#articles_controller.rb
7 changes: 6 additions & 1 deletion app/controllers/outquotes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ class OutquotesController < ApplicationController

# GET /outquotes
def index
@outquotes = Outquote.all
if params[:limit]
@outquotes = Outquote.first(params[:limit])
else
@outquotes = Outquote.all
end
if params[:article_id]
@outquotes = Article.friendly.find(params[:article_id]).outquotes
end

render json: @outquotes
end

Expand Down
1 change: 1 addition & 0 deletions app/controllers/subscribers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class SubscribersController < ApplicationController
before_action :set_subscriber, only: [:show, :update, :destroy]
before_action :authenticate_admin!, only: [:create, :update, :destroy]

# GET /subscribers
def index
Expand Down
13 changes: 3 additions & 10 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,9 @@
# :address => "localhost", :port => 1025
# }

config.action_mailer.default_url_options = { :host => 'api.stuyspec.com'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => '[email protected]',
:password => ENV['EMAIL_PASSWORD'],
:authentication => 'plain',
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = { :host => 'api.stuyspec.com'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}

config.paperclip_defaults = {
:storage => :s3,
Expand Down
1 change: 1 addition & 0 deletions db/.#schema.rb
23 changes: 17 additions & 6 deletions spec/requests/articles_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
require 'rails_helper'

RSpec.describe "Articles", type: :request do
before(:all) do
@user = User.find_or_create_by(
email: "[email protected]",
)
end
describe "GET /articles" do
it "returns correct types" do
get articles_path
get articles_path, params: { limit: 10 }
expect_json_types(
'*',
'?',
title: :string,
slug: :string,
content: :string
Expand All @@ -15,7 +20,8 @@

describe "POST /articles" do
it "creates new article" do
post articles_path,
auth_token = @user.create_new_auth_token
post(articles_path,
params: {
article: {
title: 'My article',
Expand All @@ -25,12 +31,15 @@
is_published: false,
},
section_id: 1
}
},
headers: auth_token
)
end
end

describe "PUT /articles" do
it "updates article" do
auth_token = @user.create_new_auth_token
article = Article.first
put article_path(article),
params: {
Expand All @@ -41,14 +50,16 @@
issue: 2,
is_published: false,
}
}
},
headers: auth_token
end
end

describe "DELETE /articles" do
it "deletes article" do
auth_token = @user.create_new_auth_token
article = Article.first
delete article_path(article)
delete article_path(article), headers: auth_token
end
end
end
2 changes: 1 addition & 1 deletion spec/requests/authorships_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
it 'returns correct types' do
get authorships_path
expect_json_types(
'*',
'?',
user_id: :integer,
article_id: :integer
)
Expand Down
8 changes: 6 additions & 2 deletions spec/requests/outquotes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
RSpec.describe "Outquotes", type: :request do
describe "GET /outquotes" do
it "works! (now write some real specs)" do
get outquotes_path
expect(response).to have_http_status(200)
get outquotes_path, params: { limit: 10 }
expect_json_types(
'?',
text: :string,
article_id: :integer
)
end
end
end
4 changes: 2 additions & 2 deletions spec/requests/user_roles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

RSpec.describe "UserRoles", type: :request do
describe "GET /user_roles" do
it "works! (now write some real specs)" do
get user_roles_path
it "has the right types" do
get user_roles_path, params: { limit: 10 }
expect(response).to have_http_status(200)
end
end
Expand Down

0 comments on commit d2d28fc

Please sign in to comment.