-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
112 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ WORKDIR /indicaAi | |
COPY ./indicaAi /indicaAi | ||
|
||
RUN bundle install | ||
RUN rake db:migrate | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,5 @@ build: | |
web: Dockerfile | ||
config: | ||
RAILS_ENV: production | ||
release: | ||
command: | ||
- rake db:migrate | ||
run: | ||
web: puma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Local Images Controller | ||
class LocalImagesController < ApplicationController | ||
def receive_image | ||
local = Local.find(params[:id]) | ||
if local.present? | ||
images = params[:image] | ||
images.each do |image| | ||
LocalImage.create(image: image, local_id: params[:id]) | ||
end | ||
response_success('SUCCESS', 'Images saved', 200) | ||
else | ||
response_error('ERROR', 'Place not found', 422) | ||
end | ||
end | ||
|
||
private | ||
|
||
def local_images_params | ||
params.require(:local_id).permit(images: []) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Model of LocalImage | ||
class LocalImage < ApplicationRecord | ||
belongs_to :local | ||
mount_uploaders :images, ImageUploader | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Load the Rails application. | ||
require_relative 'application' | ||
require 'carrierwave/orm/activerecord' | ||
|
||
# Initialize the Rails application. | ||
Rails.application.initialize! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CreateLocalImages < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :local_images do |t| | ||
t.text :image | ||
t.references :local, foreign_key: true | ||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe LocalImagesController, type: :controller do | ||
let!(:local) { create(:local) } | ||
images = [Faker::ChuckNorris.fact, Faker::ChuckNorris.fact] | ||
let!(:valid_params) do | ||
{ | ||
id: local.id, | ||
image: images | ||
} | ||
end | ||
describe 'POST #recive_image' do | ||
it 'Should return sucess, Image Saved' do | ||
post :receive_image, params: valid_params | ||
expect(response).to be_success | ||
end | ||
end | ||
|
||
describe 'POST #recive_image' do | ||
it 'Should return ERROR, Image not saved' do | ||
# local_id invalid | ||
valid_params['id'] = 'hi' | ||
post :receive_image, params: valid_params | ||
expect(response).to have_http_status(404) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe LocalImage, type: :model do | ||
describe 'validations' do | ||
it { should belong_to(:local) } | ||
end | ||
end |