Merge branch 'jflemingprod-feature/4143-port_to_strong_parameters' into develop
This commit is contained in:
commit
2055a0aef8
26 changed files with 93 additions and 72 deletions
5
Gemfile
5
Gemfile
|
|
@ -65,6 +65,11 @@ gem 'redcarpet', '3.0.0'
|
||||||
gem 'roxml', '3.1.6'
|
gem 'roxml', '3.1.6'
|
||||||
gem 'ruby-oembed', '0.8.8'
|
gem 'ruby-oembed', '0.8.8'
|
||||||
|
|
||||||
|
|
||||||
|
# Please remove when migrating to Rails 4
|
||||||
|
gem 'strong_parameters'
|
||||||
|
|
||||||
|
|
||||||
# Services
|
# Services
|
||||||
|
|
||||||
gem 'omniauth', '1.1.4'
|
gem 'omniauth', '1.1.4'
|
||||||
|
|
|
||||||
|
|
@ -380,6 +380,10 @@ GEM
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
|
strong_parameters (0.2.1)
|
||||||
|
actionpack (~> 3.0)
|
||||||
|
activemodel (~> 3.0)
|
||||||
|
railties (~> 3.0)
|
||||||
subexec (0.2.3)
|
subexec (0.2.3)
|
||||||
temple (0.6.6)
|
temple (0.6.6)
|
||||||
thor (0.18.1)
|
thor (0.18.1)
|
||||||
|
|
@ -486,6 +490,7 @@ DEPENDENCIES
|
||||||
sinon-rails (= 1.7.3)
|
sinon-rails (= 1.7.3)
|
||||||
slim (= 1.3.9)
|
slim (= 1.3.9)
|
||||||
spork (= 1.0.0rc3)
|
spork (= 1.0.0rc3)
|
||||||
|
strong_parameters
|
||||||
timecop (= 0.6.1)
|
timecop (= 0.6.1)
|
||||||
twitter (= 4.8.1)
|
twitter (= 4.8.1)
|
||||||
typhoeus (= 0.6.3)
|
typhoeus (= 0.6.3)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class AspectsController < ApplicationController
|
||||||
:json
|
:json
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@aspect = current_user.aspects.build(params[:aspect])
|
@aspect = current_user.aspects.build(aspect_params)
|
||||||
aspecting_person_id = params[:aspect][:person_id]
|
aspecting_person_id = params[:aspect][:person_id]
|
||||||
|
|
||||||
if @aspect.save
|
if @aspect.save
|
||||||
|
|
@ -92,7 +92,7 @@ class AspectsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
@aspect = current_user.aspects.where(:id => params[:id]).first
|
@aspect = current_user.aspects.where(:id => params[:id]).first
|
||||||
|
|
||||||
if @aspect.update_attributes!(params[:aspect])
|
if @aspect.update_attributes!(aspect_params)
|
||||||
flash[:notice] = I18n.t 'aspects.update.success', :name => @aspect.name
|
flash[:notice] = I18n.t 'aspects.update.success', :name => @aspect.name
|
||||||
else
|
else
|
||||||
flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name
|
flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name
|
||||||
|
|
@ -121,4 +121,8 @@ class AspectsController < ApplicationController
|
||||||
@contact = current_user.share_with(@person, @aspect)
|
@contact = current_user.share_with(@person, @aspect)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def aspect_params
|
||||||
|
params.require(:aspect).permit(:name, :contacts_visible, :order_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class BlocksController < ApplicationController
|
||||||
respond_to :html, :json
|
respond_to :html, :json
|
||||||
|
|
||||||
def create
|
def create
|
||||||
block = current_user.blocks.new(params[:block])
|
block = current_user.blocks.new(block_params)
|
||||||
|
|
||||||
if block.save
|
if block.save
|
||||||
disconnect_if_contact(block.person)
|
disconnect_if_contact(block.person)
|
||||||
|
|
@ -39,4 +39,8 @@ class BlocksController < ApplicationController
|
||||||
current_user.disconnect(contact, :force => true)
|
current_user.disconnect(contact, :force => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def block_params
|
||||||
|
params.require(:block).permit(:person_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,14 @@ class ConversationsController < ApplicationController
|
||||||
person_ids = Contact.where(:id => params[:contact_ids].split(',')).map(&:person_id)
|
person_ids = Contact.where(:id => params[:contact_ids].split(',')).map(&:person_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
params[:conversation][:participant_ids] = [*person_ids] | [current_user.person_id]
|
@conversation = Conversation.new
|
||||||
params[:conversation][:author] = current_user.person
|
@conversation.subject = params[:conversation][:subject]
|
||||||
message_text = params[:conversation].delete(:text)
|
@conversation.participant_ids = [*person_ids] | [current_user.person_id]
|
||||||
params[:conversation][:messages_attributes] = [ {:author => current_user.person, :text => message_text }]
|
@conversation.author = current_user.person
|
||||||
|
message_text = params[:conversation][:text]
|
||||||
|
@conversation.messages_attributes = [ {:author => current_user.person, :text => message_text }]
|
||||||
|
|
||||||
@response = {}
|
@response = {}
|
||||||
@conversation = Conversation.new(params[:conversation])
|
|
||||||
if person_ids.present? && @conversation.save
|
if person_ids.present? && @conversation.save
|
||||||
Postzord::Dispatcher.build(current_user, @conversation).post
|
Postzord::Dispatcher.build(current_user, @conversation).post
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class InvitationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
emails = params[:email_inviter][:emails].split(',').map(&:strip).uniq
|
emails = inviter_params[:emails].split(',').map(&:strip).uniq
|
||||||
|
|
||||||
valid_emails, invalid_emails = emails.partition { |email| valid_email?(email) }
|
valid_emails, invalid_emails = emails.partition { |email| valid_email?(email) }
|
||||||
|
|
||||||
|
|
@ -60,8 +60,7 @@ class InvitationsController < ApplicationController
|
||||||
unless valid_emails.empty?
|
unless valid_emails.empty?
|
||||||
Workers::Mail::InviteEmail.perform_async(valid_emails.join(','),
|
Workers::Mail::InviteEmail.perform_async(valid_emails.join(','),
|
||||||
current_user.id,
|
current_user.id,
|
||||||
params[:email_inviter])
|
inviter_params)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if emails.empty?
|
if emails.empty?
|
||||||
|
|
@ -99,4 +98,8 @@ class InvitationsController < ApplicationController
|
||||||
session[key] = nil
|
session[key] = nil
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inviter_params
|
||||||
|
params.require(:email_inviter).permit(:message, :locale, :emails)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class PhotosController < ApplicationController
|
||||||
def create
|
def create
|
||||||
rescuing_photo_errors do
|
rescuing_photo_errors do
|
||||||
if remotipart_submitted?
|
if remotipart_submitted?
|
||||||
@photo = current_user.build_post(:photo, params[:photo])
|
@photo = current_user.build_post(:photo, photo_params)
|
||||||
if @photo.save
|
if @photo.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json { render :json => {"success" => true, "data" => @photo.as_api_response(:backbone)} }
|
format.json { render :json => {"success" => true, "data" => @photo.as_api_response(:backbone)} }
|
||||||
|
|
@ -114,7 +114,7 @@ class PhotosController < ApplicationController
|
||||||
def update
|
def update
|
||||||
photo = current_user.photos.where(:id => params[:id]).first
|
photo = current_user.photos.where(:id => params[:id]).first
|
||||||
if photo
|
if photo
|
||||||
if current_user.update_post( photo, params[:photo] )
|
if current_user.update_post( photo, photo_params )
|
||||||
flash.now[:notice] = I18n.t 'photos.update.notice'
|
flash.now[:notice] = I18n.t 'photos.update.notice'
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js{ render :json => photo, :status => 200 }
|
format.js{ render :json => photo, :status => 200 }
|
||||||
|
|
@ -133,6 +133,10 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def photo_params
|
||||||
|
params.require(:photo).permit(:public, :text, :pending, :user_file, :image_url, :aspect_ids, :set_profile_photo)
|
||||||
|
end
|
||||||
|
|
||||||
def file_handler(params)
|
def file_handler(params)
|
||||||
# For XHR file uploads, request.params[:qqfile] will be the path to the temporary file
|
# For XHR file uploads, request.params[:qqfile] will be the path to the temporary file
|
||||||
# For regular form uploads (such as those made by Opera), request.params[:qqfile] will be an UploadedFile which can be returned unaltered.
|
# For regular form uploads (such as those made by Opera), request.params[:qqfile] will be an UploadedFile which can be returned unaltered.
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class ProfilesController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
# upload and set new profile photo
|
# upload and set new profile photo
|
||||||
@profile_attrs = params[:profile] || {}
|
@profile_attrs = profile_params
|
||||||
|
|
||||||
munge_tag_string
|
munge_tag_string
|
||||||
|
|
||||||
|
|
@ -78,4 +78,8 @@ class ProfilesController < ApplicationController
|
||||||
end
|
end
|
||||||
@profile_attrs[:tag_string] = (params[:tags]) ? params[:tags].gsub(',',' ') : ""
|
@profile_attrs[:tag_string] = (params[:tags]) ? params[:tags].gsub(',',' ') : ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def profile_params
|
||||||
|
params.require(:profile).permit(:first_name, :last_name, :gender, :bio, :location, :searchable, :tag_string, :nsfw, :date => [:year, :month, :day]) || {}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
before_filter -> { @css_framework = :bootstrap }, only: [:new]
|
before_filter -> { @css_framework = :bootstrap }, only: [:new]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@user = User.build(params[:user])
|
@user = User.build(user_params)
|
||||||
@user.process_invite_acceptence(invite) if invite.present?
|
@user.process_invite_acceptence(invite) if invite.present?
|
||||||
|
|
||||||
if @user.save
|
if @user.save
|
||||||
|
|
@ -54,4 +54,8 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
helper_method :invite
|
helper_method :invite
|
||||||
|
|
||||||
|
def user_params
|
||||||
|
params.require(:user).permit(:username, :email, :getting_started, :password, :password_confirmation, :language, :disable_mail, :invitation_service, :invitation_identifier, :show_community_spotlight_in_stream, :auto_follow_back, :auto_follow_back_aspect_id, :remember_me)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class UsersController < ApplicationController
|
||||||
password_changed = false
|
password_changed = false
|
||||||
@user = current_user
|
@user = current_user
|
||||||
|
|
||||||
if u = params[:user]
|
if u = user_params
|
||||||
u.delete(:password) if u[:password].blank?
|
u.delete(:password) if u[:password].blank?
|
||||||
u.delete(:password_confirmation) if u[:password].blank? and u[:password_confirmation].blank?
|
u.delete(:password_confirmation) if u[:password].blank? and u[:password_confirmation].blank?
|
||||||
u.delete(:language) if u[:language].blank?
|
u.delete(:language) if u[:language].blank?
|
||||||
|
|
@ -125,7 +125,8 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def getting_started_completed
|
def getting_started_completed
|
||||||
user = current_user
|
user = current_user
|
||||||
user.update_attributes(:getting_started => false)
|
user.getting_started = false
|
||||||
|
user.save
|
||||||
redirect_to stream_path
|
redirect_to stream_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -157,4 +158,10 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
redirect_to edit_user_path
|
redirect_to edit_user_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def user_params
|
||||||
|
params.fetch(:user).permit(:username, :email, :current_password, :password, :password_confirmation, :language, :disable_mail, :invitation_service, :invitation_identifier, :show_community_spotlight_in_stream, :auto_follow_back, :auto_follow_back_aspect_id, :remember_me, :email_preferences => [:also_commented, :mentioned, :comment_on_post, :private_message, :started_sharing, :liked, :reshared])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ class AccountDeletion < ActiveRecord::Base
|
||||||
belongs_to :person
|
belongs_to :person
|
||||||
after_create :queue_delete_account
|
after_create :queue_delete_account
|
||||||
|
|
||||||
attr_accessible :person
|
|
||||||
|
|
||||||
xml_name :account_deletion
|
xml_name :account_deletion
|
||||||
xml_attr :diaspora_handle
|
xml_attr :diaspora_handle
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@ class Aspect < ActiveRecord::Base
|
||||||
|
|
||||||
validates_uniqueness_of :name, :scope => :user_id, :case_sensitive => false
|
validates_uniqueness_of :name, :scope => :user_id, :case_sensitive => false
|
||||||
|
|
||||||
attr_accessible :name, :contacts_visible, :order_id
|
|
||||||
|
|
||||||
before_validation do
|
before_validation do
|
||||||
name.strip!
|
name.strip!
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ class Invitation < ActiveRecord::Base
|
||||||
belongs_to :recipient, :class_name => 'User'
|
belongs_to :recipient, :class_name => 'User'
|
||||||
belongs_to :aspect
|
belongs_to :aspect
|
||||||
|
|
||||||
attr_accessible :sender, :recipient, :aspect, :language, :service, :identifier, :admin, :message
|
|
||||||
|
|
||||||
before_validation :set_email_as_default_service
|
before_validation :set_email_as_default_service
|
||||||
|
|
||||||
# before_create :share_with_exsisting_user, :if => :recipient_id?
|
# before_create :share_with_exsisting_user, :if => :recipient_id?
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
class OEmbedCache < ActiveRecord::Base
|
class OEmbedCache < ActiveRecord::Base
|
||||||
serialize :data
|
serialize :data
|
||||||
attr_accessible :url
|
|
||||||
validates :data, :presence => true
|
validates :data, :presence => true
|
||||||
|
|
||||||
has_many :posts
|
has_many :posts
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ class Photo < ActiveRecord::Base
|
||||||
validates_associated :status_message
|
validates_associated :status_message
|
||||||
delegate :author_name, to: :status_message, prefix: true
|
delegate :author_name, to: :status_message, prefix: true
|
||||||
|
|
||||||
attr_accessible :text, :pending
|
|
||||||
validate :ownership_of_status_message
|
validate :ownership_of_status_message
|
||||||
|
|
||||||
before_destroy :ensure_user_picture
|
before_destroy :ensure_user_picture
|
||||||
|
|
@ -69,7 +68,7 @@ class Photo < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.diaspora_initialize(params = {})
|
def self.diaspora_initialize(params = {})
|
||||||
photo = self.new params.to_hash
|
photo = self.new params.to_hash.slice(:text, :pending)
|
||||||
photo.author = params[:author]
|
photo.author = params[:author]
|
||||||
photo.public = params[:public] if params[:public]
|
photo.public = params[:public] if params[:public]
|
||||||
photo.pending = params[:pending] if params[:pending]
|
photo.pending = params[:pending] if params[:pending]
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class Post < ActiveRecord::Base
|
||||||
#############
|
#############
|
||||||
|
|
||||||
def self.diaspora_initialize(params)
|
def self.diaspora_initialize(params)
|
||||||
new_post = self.new params.to_hash
|
new_post = self.new params.to_hash.stringify_keys.slice(*self.column_names)
|
||||||
new_post.author = params[:author]
|
new_post.author = params[:author]
|
||||||
new_post.public = params[:public] if params[:public]
|
new_post.public = params[:public] if params[:public]
|
||||||
new_post.pending = params[:pending] if params[:pending]
|
new_post.pending = params[:pending] if params[:pending]
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,6 @@ class Profile < ActiveRecord::Base
|
||||||
validate :max_tags
|
validate :max_tags
|
||||||
validate :valid_birthday
|
validate :valid_birthday
|
||||||
|
|
||||||
attr_accessible :first_name, :last_name, :image_url, :image_url_medium,
|
|
||||||
:image_url_small, :birthday, :gender, :bio, :location, :searchable, :date, :tag_string, :nsfw
|
|
||||||
|
|
||||||
belongs_to :person
|
belongs_to :person
|
||||||
before_validation do
|
before_validation do
|
||||||
self.tag_string = self.tag_string.split[0..4].join(' ')
|
self.tag_string = self.tag_string.split[0..4].join(' ')
|
||||||
|
|
@ -57,7 +54,8 @@ class Profile < ActiveRecord::Base
|
||||||
|
|
||||||
def receive(user, person)
|
def receive(user, person)
|
||||||
Rails.logger.info("event=receive payload_type=profile sender=#{person} to=#{user}")
|
Rails.logger.info("event=receive payload_type=profile sender=#{person} to=#{user}")
|
||||||
person.profile.update_attributes self.attributes.merge(:tag_string => self.tag_string)
|
profiles_attr = self.attributes.merge('tag_string' => self.tag_string).slice('diaspora_handle', 'first_name', 'last_name', 'image_url', 'image_url_small', 'image_url_medium', 'birthday', 'gender', 'bio', 'location', 'searchable', 'nsfw', 'tag_string')
|
||||||
|
person.profile.update_attributes(profiles_attr)
|
||||||
|
|
||||||
person.profile
|
person.profile
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ class Reshare < Post
|
||||||
|
|
||||||
belongs_to :root, :class_name => 'Post', :foreign_key => :root_guid, :primary_key => :guid
|
belongs_to :root, :class_name => 'Post', :foreign_key => :root_guid, :primary_key => :guid
|
||||||
validate :root_must_be_public
|
validate :root_must_be_public
|
||||||
attr_accessible :root_guid, :public
|
|
||||||
validates_presence_of :root, :on => :create
|
validates_presence_of :root, :on => :create
|
||||||
validates_uniqueness_of :root_guid, :scope => :author_id
|
validates_uniqueness_of :root_guid, :scope => :author_id
|
||||||
delegate :author, to: :root, prefix: true
|
delegate :author, to: :root, prefix: true
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ class StatusMessage < Post
|
||||||
# therefore, we put the validation in a before_destory callback instead of a validation
|
# therefore, we put the validation in a before_destory callback instead of a validation
|
||||||
before_destroy :presence_of_content
|
before_destroy :presence_of_content
|
||||||
|
|
||||||
attr_accessible :text, :provider_display_name, :frame_name
|
|
||||||
attr_accessor :oembed_url
|
attr_accessor :oembed_url
|
||||||
|
|
||||||
before_create :filter_mentions
|
before_create :filter_mentions
|
||||||
|
|
|
||||||
|
|
@ -63,25 +63,9 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :notifications, :foreign_key => :recipient_id
|
has_many :notifications, :foreign_key => :recipient_id
|
||||||
|
|
||||||
|
|
||||||
before_save :guard_unconfirmed_email,
|
before_save :guard_unconfirmed_email,
|
||||||
:save_person!
|
:save_person!
|
||||||
|
|
||||||
attr_accessible :username,
|
|
||||||
:email,
|
|
||||||
:getting_started,
|
|
||||||
:password,
|
|
||||||
:password_confirmation,
|
|
||||||
:language,
|
|
||||||
:disable_mail,
|
|
||||||
:invitation_service,
|
|
||||||
:invitation_identifier,
|
|
||||||
:show_community_spotlight_in_stream,
|
|
||||||
:auto_follow_back,
|
|
||||||
:auto_follow_back_aspect_id,
|
|
||||||
:remember_me
|
|
||||||
|
|
||||||
|
|
||||||
def self.all_sharing_with_person(person)
|
def self.all_sharing_with_person(person)
|
||||||
User.joins(:contacts).where(:contacts => {:person_id => person.id})
|
User.joins(:contacts).where(:contacts => {:person_id => person.id})
|
||||||
end
|
end
|
||||||
|
|
@ -342,6 +326,8 @@ class User < ActiveRecord::Base
|
||||||
params[:image_url_small] = photo.url(:thumb_small)
|
params[:image_url_small] = photo.url(:thumb_small)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
params.stringify_keys!
|
||||||
|
params.slice!(*(Profile.column_names+['tag_string', 'date']))
|
||||||
if self.profile.update_attributes(params)
|
if self.profile.update_attributes(params)
|
||||||
deliver_profile_update
|
deliver_profile_update
|
||||||
true
|
true
|
||||||
|
|
@ -356,7 +342,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
###Helpers############
|
###Helpers############
|
||||||
def self.build(opts = {})
|
def self.build(opts = {})
|
||||||
u = User.new(opts)
|
u = User.new(opts.except(:person))
|
||||||
u.setup(opts)
|
u.setup(opts)
|
||||||
u
|
u
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ module Diaspora
|
||||||
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
||||||
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
||||||
# parameters by using an attr_accessible or attr_protected declaration.
|
# parameters by using an attr_accessible or attr_protected declaration.
|
||||||
#config.active_record.whitelist_attributes = true
|
#config.active_record.whitelist_attributes = false
|
||||||
|
|
||||||
# Enable the asset pipeline
|
# Enable the asset pipeline
|
||||||
config.assets.enabled = true
|
config.assets.enabled = true
|
||||||
|
|
|
||||||
2
config/initializers/strong_parameters.rb
Normal file
2
config/initializers/strong_parameters.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Please remove when migrating to Rails 4
|
||||||
|
ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection)
|
||||||
|
|
@ -54,6 +54,20 @@ describe PhotosController do
|
||||||
}.should change(Photo, :count).by(1)
|
}.should change(Photo, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't allow mass assignment of person" do
|
||||||
|
new_user = FactoryGirl.create(:user)
|
||||||
|
@params[:photo][:author] = new_user
|
||||||
|
post :create, @params
|
||||||
|
Photo.last.author.should == alice.person
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't allow mass assignment of person_id" do
|
||||||
|
new_user = FactoryGirl.create(:user)
|
||||||
|
@params[:photo][:author_id] = new_user.id
|
||||||
|
post :create, @params
|
||||||
|
Photo.last.author.should == alice.person
|
||||||
|
end
|
||||||
|
|
||||||
it 'can set the photo as the profile photo' do
|
it 'can set the photo as the profile photo' do
|
||||||
old_url = alice.person.profile.image_url
|
old_url = alice.person.profile.image_url
|
||||||
@params[:photo][:set_profile_photo] = true
|
@params[:photo][:set_profile_photo] = true
|
||||||
|
|
@ -137,7 +151,14 @@ describe PhotosController do
|
||||||
@alices_photo.reload.text.should == "now with lasers!"
|
@alices_photo.reload.text.should == "now with lasers!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't overwrite random attributes" do
|
it "doesn't allow mass assignment of person" do
|
||||||
|
new_user = FactoryGirl.create(:user)
|
||||||
|
params = { :text => "now with lasers!", :author => new_user }
|
||||||
|
put :update, :id => @alices_photo.id, :photo => params
|
||||||
|
@alices_photo.reload.author.should == alice.person
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't allow mass assignment of person_id" do
|
||||||
new_user = FactoryGirl.create(:user)
|
new_user = FactoryGirl.create(:user)
|
||||||
params = { :text => "now with lasers!", :author_id => new_user.id }
|
params = { :text => "now with lasers!", :author_id => new_user.id }
|
||||||
put :update, :id => @alices_photo.id, :photo => params
|
put :update, :id => @alices_photo.id, :photo => params
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,8 @@ describe ProfilesController do
|
||||||
|
|
||||||
it 'sets tags' do
|
it 'sets tags' do
|
||||||
params = { :id => eve.person.id,
|
params = { :id => eve.person.id,
|
||||||
:tags => '#apples #oranges'}
|
:tags => '#apples #oranges',
|
||||||
|
:profile => {:tag_string => ''} }
|
||||||
|
|
||||||
put :update, params
|
put :update, params
|
||||||
eve.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set
|
eve.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set
|
||||||
|
|
|
||||||
|
|
@ -26,24 +26,6 @@ describe Photo do
|
||||||
@saved_photo.save
|
@saved_photo.save
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "protected attributes" do
|
|
||||||
it "doesn't allow mass assignment of person" do
|
|
||||||
@photo.save!
|
|
||||||
@photo.update_attributes(:author => FactoryGirl.build(:person))
|
|
||||||
@photo.reload.author.should == @user.person
|
|
||||||
end
|
|
||||||
it "doesn't allow mass assignment of person_id" do
|
|
||||||
@photo.save!
|
|
||||||
@photo.update_attributes(:author_id => FactoryGirl.build(:person).id)
|
|
||||||
@photo.reload.author.should == @user.person
|
|
||||||
end
|
|
||||||
it 'allows assignment of text' do
|
|
||||||
@photo.save!
|
|
||||||
@photo.update_attributes(:text => "this is awesome!!")
|
|
||||||
@photo.reload.text.should == "this is awesome!!"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'after_create' do
|
describe 'after_create' do
|
||||||
it 'calls #queue_processing_job' do
|
it 'calls #queue_processing_job' do
|
||||||
@photo.should_receive(:queue_processing_job)
|
@photo.should_receive(:queue_processing_job)
|
||||||
|
|
|
||||||
|
|
@ -466,7 +466,7 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'dispatches the profile when tags are set' do
|
it 'dispatches the profile when tags are set' do
|
||||||
@params = {:tags => '#what #hey'}
|
@params = {:tag_string => '#what #hey'}
|
||||||
mailman = Postzord::Dispatcher.build(alice, Profile.new)
|
mailman = Postzord::Dispatcher.build(alice, Profile.new)
|
||||||
Postzord::Dispatcher.should_receive(:build).and_return(mailman)
|
Postzord::Dispatcher.should_receive(:build).and_return(mailman)
|
||||||
alice.update_profile(@params).should be_true
|
alice.update_profile(@params).should be_true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue