indent using spaces

This commit is contained in:
shlok007 2017-05-31 19:35:43 +05:30
parent b1fac33420
commit ae1f292719
4 changed files with 41 additions and 43 deletions

View file

@ -1,41 +1,40 @@
class OrganizationsController < ApplicationController class OrganizationsController < ApplicationController
load_and_authorize_resource :organization load_and_authorize_resource :organization
def index def index
@organizations = Organization.all @organizations = Organization.all
end end
def create def create
@organization = Organization.new(organization_params) @organization = Organization.new(organization_params)
if @organization.save if @organization.save
redirect_to organizations_path, redirect_to organizations_path,
notice: 'Organization successfully created' notice: 'Organization successfully created'
else else
redirect_to new_organization_path, redirect_to new_organization_path,
error: @organization.errors.full_messages.join(', ') error: @organization.errors.full_messages.join(', ')
end end
end end
def new def new
@organization = Organization.new @organization = Organization.new
end end
def edit def edit; end
end
def update def update
if @organization.update_attributes(organization_params) if @organization.update_attributes(organization_params)
redirect_to organizations_path, redirect_to organizations_path,
notice: 'Organization successfully updated' notice: 'Organization successfully updated'
else else
redirect_to edit_organization_path(@organization), redirect_to edit_organization_path(@organization),
error: @organization.errors.full_messages.join(', ') error: @organization.errors.full_messages.join(', ')
end end
end end
private private
def organization_params def organization_params
params.require(:organization).permit(:name, :description, :picture) params.require(:organization).permit(:name, :description, :picture)
end end
end end

View file

@ -4,4 +4,4 @@ class Organization < ActiveRecord::Base
validates :name, presence: true validates :name, presence: true
mount_uploader :picture, PictureUploader, mount_on: :picture mount_uploader :picture, PictureUploader, mount_on: :picture
end end

View file

@ -1,13 +1,13 @@
FactoryGirl.define do FactoryGirl.define do
factory :organization do factory :organization do
name { Faker::Company.name } name { Faker::Company.name }
description { Faker::Lorem.paragraph } description { Faker::Lorem.paragraph }
# after(:create) do |organization| # after(:create) do |organization|
# File.open("spec/support/logos/#{1 + rand(13)}.png") do |file| # File.open("spec/support/logos/#{1 + rand(13)}.png") do |file|
# organization.picture = file # organization.picture = file
# end # end
# organization.save! # organization.save!
# end # end
end end
end end

View file

@ -5,7 +5,7 @@ describe Organization do
describe 'validation' do describe 'validation' do
it 'has a valid factory' do it 'has a valid factory' do
expect( build(:organization) ).to be_valid expect(build(:organization)).to be_valid
end end
it 'is not valid without a name' do it 'is not valid without a name' do
@ -17,4 +17,3 @@ describe Organization do
it { should have_many(:conferences).dependent(:destroy) } it { should have_many(:conferences).dependent(:destroy) }
end end
end end