-
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.
Merge pull request #271 from fga-eps-mds/feature/264-Adding-Locals-Image
Feature/264 adding locals image
- Loading branch information
Showing
18 changed files
with
111 additions
and
21 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
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,12 @@ | ||
# Local Images Controller | ||
class LocalImagesController < ApplicationController | ||
def receive_image | ||
local = Local.find(params[:id]) | ||
return response_success('ERROR', 404) unless local.present? | ||
images = params[:image] | ||
images.each do |image| | ||
LocalImage.create(image: image, local_id: params[:id]) | ||
end | ||
response_success('SUCCESS', 'Images saved', 200) | ||
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Class of ImageUploader | ||
class ImageUploader < CarrierWave::Uploader::Base | ||
include CarrierWave::MiniMagick | ||
|
||
storage :file | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 have status 404' 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 |