Commit d486c3ff8d7a02944552a529df632ae6ff632319

Authored by Braulio Bhavamitra
1 parent b71858da

rails4: replace update_attributes with the new update

Showing 60 changed files with 98 additions and 98 deletions   Show diff stats
app/controllers/admin/admin_panel_controller.rb
... ... @@ -12,7 +12,7 @@ class AdminPanelController < AdminController
12 12 if params[:environment][:languages]
13 13 params[:environment][:languages] = params[:environment][:languages].map {|lang, value| lang if value=='true'}.compact
14 14 end
15   - if @environment.update_attributes(params[:environment])
  15 + if @environment.update(params[:environment])
16 16 session[:notice] = _('Environment settings updated')
17 17 redirect_to :action => 'index'
18 18 end
... ... @@ -65,7 +65,7 @@ class AdminPanelController < AdminController
65 65  
66 66 def set_portal_news_amount
67 67 if request.post?
68   - if @environment.update_attributes(params[:environment])
  68 + if @environment.update(params[:environment])
69 69 session[:notice] = _('Saved the number of news on folders')
70 70 redirect_to :action => 'index'
71 71 end
... ...
app/controllers/admin/categories_controller.rb
... ... @@ -43,7 +43,7 @@ class CategoriesController < AdminController
43 43 begin
44 44 @category = environment.categories.find(params[:id])
45 45 if request.post?
46   - @category.update_attributes!(params[:category])
  46 + @category.update!(params[:category])
47 47 @saved = true
48 48 session[:notice] = _("Category %s saved." % @category.name)
49 49 redirect_to :action => 'index'
... ...
app/controllers/admin/features_controller.rb
... ... @@ -7,7 +7,7 @@ class FeaturesController < AdminController
7 7  
8 8 post_only :update
9 9 def update
10   - if @environment.update_attributes(params[:environment])
  10 + if @environment.update(params[:environment])
11 11 session[:notice] = _('Features updated successfully.')
12 12 redirect_to :action => 'index'
13 13 else
... ...
app/controllers/admin/licenses_controller.rb
... ... @@ -23,7 +23,7 @@ class LicensesController < AdminController
23 23 @license = environment.licenses.find(params[:license_id])
24 24 if request.post?
25 25 begin
26   - @license.update_attributes!(params[:license])
  26 + @license.update!(params[:license])
27 27 session[:notice] = _('License updated')
28 28 redirect_to :action => 'index'
29 29 rescue
... ...
app/controllers/admin/plugins_controller.rb
... ... @@ -8,7 +8,7 @@ class PluginsController < AdminController
8 8 post_only :update
9 9 def update
10 10 params[:environment][:enabled_plugins].delete('')
11   - if @environment.update_attributes(params[:environment])
  11 + if @environment.update(params[:environment])
12 12 session[:notice] = _('Plugins updated successfully.')
13 13 else
14 14 session[:error] = _('Plugins were not updated successfully.')
... ...
app/controllers/admin/role_controller.rb
... ... @@ -29,7 +29,7 @@ class RoleController < AdminController
29 29  
30 30 def update
31 31 @role = environment.roles.find(params[:id])
32   - if @role.update_attributes(params[:role])
  32 + if @role.update(params[:role])
33 33 redirect_to :action => 'show', :id => @role
34 34 else
35 35 session[:notice] = _('Failed to edit role')
... ...
app/controllers/box_organizer_controller.rb
... ... @@ -98,7 +98,7 @@ class BoxOrganizerController < ApplicationController
98 98  
99 99 def save
100 100 @block = boxes_holder.blocks.find(params[:id])
101   - @block.update_attributes(params[:block])
  101 + @block.update(params[:block])
102 102 redirect_to :action => 'index'
103 103 end
104 104  
... ...
app/controllers/my_profile/cms_controller.rb
... ... @@ -93,7 +93,7 @@ class CmsController < MyProfileController
93 93 @article.image.save!
94 94 end
95 95 @article.last_changed_by = user
96   - if @article.update_attributes(params[:article])
  96 + if @article.update(params[:article])
97 97 if !continue
98 98 if @article.content_type.nil? || @article.image?
99 99 success_redirect
... ...
app/controllers/my_profile/enterprise_validation_controller.rb
... ... @@ -54,7 +54,7 @@ class EnterpriseValidationController < MyProfileController
54 54 def edit_validation_info
55 55 @info = profile.validation_info
56 56 if request.post?
57   - if @info.update_attributes(params[:info])
  57 + if @info.update(params[:info])
58 58 redirect_to :action => 'index'
59 59 end
60 60 end
... ...
app/controllers/my_profile/manage_products_controller.rb
... ... @@ -69,7 +69,7 @@ class ManageProductsController < ApplicationController
69 69 field = params[:field]
70 70 if request.post?
71 71 begin
72   - @product.update_attributes!(params[:product])
  72 + @product.update!(params[:product])
73 73 render :partial => "display_#{field}", :locals => {:product => @product}
74 74 rescue Exception => e
75 75 render :partial => "edit_#{field}", :locals => {:product => @product, :errors => true}
... ... @@ -86,7 +86,7 @@ class ManageProductsController < ApplicationController
86 86 @edit = true
87 87 @level = @category.level
88 88 if request.post?
89   - if @product.update_attributes({:product_category_id => params[:selected_category_id]}, :without_protection => true)
  89 + if @product.update({:product_category_id => params[:selected_category_id]}, :without_protection => true)
90 90 render :partial => 'shared/redirect_via_javascript',
91 91 :locals => { :url => url_for(:controller => 'manage_products', :action => 'show', :id => @product) }
92 92 else
... ... @@ -115,7 +115,7 @@ class ManageProductsController < ApplicationController
115 115 @categories = ProductCategory.top_level_for(environment)
116 116 @level = 0
117 117 if request.post?
118   - if @input.update_attributes(:product_category_id => params[:selected_category_id])
  118 + if @input.update(:product_category_id => params[:selected_category_id])
119 119 @inputs = @product.inputs
120 120 render :partial => 'display_inputs'
121 121 else
... ... @@ -172,7 +172,7 @@ class ManageProductsController < ApplicationController
172 172 @input = @profile.inputs.find_by_id(params[:id])
173 173 if @input
174 174 if request.post?
175   - if @input.update_attributes(params[:input])
  175 + if @input.update(params[:input])
176 176 render :partial => 'display_input', :locals => {:input => @input}
177 177 else
178 178 render :partial => 'edit_input'
... ...
app/controllers/my_profile/maps_controller.rb
... ... @@ -15,7 +15,7 @@ class MapsController < MyProfileController
15 15 end
16 16  
17 17 Profile.transaction do
18   - if profile.update_attributes!(params[:profile_data])
  18 + if profile.update!(params[:profile_data])
19 19 BlockSweeper.expire_blocks profile.blocks.select{ |b| b.class == LocationBlock }
20 20 session[:notice] = _('Address was updated successfully!')
21 21 redirect_to :action => 'edit_location'
... ...
app/controllers/my_profile/profile_editor_controller.rb
... ... @@ -24,7 +24,7 @@ class ProfileEditorController < MyProfileController
24 24 Image.transaction do
25 25 begin
26 26 @plugins.dispatch(:profile_editor_transaction_extras)
27   - @profile_data.update_attributes!(params[:profile_data])
  27 + @profile_data.update!(params[:profile_data])
28 28 redirect_to :action => 'index', :profile => profile.identifier
29 29 rescue Exception => ex
30 30 profile.identifier = params[:profile] if profile.identifier.blank?
... ... @@ -94,7 +94,7 @@ class ProfileEditorController < MyProfileController
94 94 @welcome_page = profile.welcome_page || TinyMceArticle.new(:name => 'Welcome Page', :profile => profile, :published => false)
95 95 if request.post?
96 96 begin
97   - @welcome_page.update_attributes!(params[:welcome_page])
  97 + @welcome_page.update!(params[:welcome_page])
98 98 profile.welcome_page = @welcome_page
99 99 profile.save!
100 100 session[:notice] = _('Welcome page saved successfully.')
... ...
app/controllers/my_profile/profile_roles_controller.rb
... ... @@ -58,7 +58,7 @@ class ProfileRolesController < MyProfileController
58 58  
59 59 def update
60 60 @role = environment.roles.find(params[:id])
61   - if @role.update_attributes(params[:role])
  61 + if @role.update(params[:role])
62 62 redirect_to :action => 'show', :id => @role
63 63 else
64 64 session[:notice] = _('Failed to edit role')
... ...
app/controllers/my_profile/tasks_controller.rb
... ... @@ -48,7 +48,7 @@ class TasksController < MyProfileController
48 48 if request.post? && VALID_DECISIONS.include?(decision) && id && decision != 'skip'
49 49 task = profile.find_in_all_tasks(id)
50 50 begin
51   - task.update_attributes(value[:task])
  51 + task.update(value[:task])
52 52 task.send(decision, current_person)
53 53 rescue Exception => ex
54 54 message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})"
... ...
app/controllers/public/account_controller.rb
... ... @@ -119,7 +119,7 @@ class AccountController < ApplicationController
119 119 @user.person.affiliate(@user.person, [owner_role]) if owner_role
120 120 invitation = Task.from_code(@invitation_code).first
121 121 if invitation
122   - invitation.update_attributes! friend: @user.person
  122 + invitation.update! friend: @user.person
123 123 invitation.finish
124 124 end
125 125  
... ... @@ -218,7 +218,7 @@ class AccountController < ApplicationController
218 218  
219 219 if request.post?
220 220 begin
221   - @change_password.update_attributes!(params[:change_password])
  221 + @change_password.update!(params[:change_password])
222 222 @change_password.finish
223 223 render :action => 'new_password_ok'
224 224 rescue ActiveRecord::RecordInvalid => e
... ... @@ -487,7 +487,7 @@ class AccountController < ApplicationController
487 487 def check_redirection
488 488 unless params[:redirection].blank?
489 489 session[:return_to] = @user.return_to
490   - @user.update_attributes(:return_to => nil)
  490 + @user.update(:return_to => nil)
491 491 end
492 492 end
493 493  
... ...
app/controllers/public/chat_controller.rb
... ... @@ -67,7 +67,7 @@ class ChatController < PublicController
67 67  
68 68 def update_presence_status
69 69 if request.xhr?
70   - current_user.update_attributes({:chat_status_at => DateTime.now}.merge(params[:status] || {}))
  70 + current_user.update({:chat_status_at => DateTime.now}.merge(params[:status] || {}))
71 71 end
72 72 render :nothing => true
73 73 end
... ...
app/controllers/public/comment_controller.rb
... ... @@ -78,7 +78,7 @@ class CommentController < ApplicationController
78 78 respond_to do |format|
79 79 format.js do
80 80 comment_to_render = @comment.comment_root
81   - render :json => {
  81 + render :json => {
82 82 :render_target => comment_to_render.anchor,
83 83 :html => render_to_string(:partial => 'comment', :locals => {:comment => comment_to_render, :display_link => true}),
84 84 :msg => _('Comment successfully created.')
... ... @@ -114,7 +114,7 @@ class CommentController < ApplicationController
114 114 end
115 115  
116 116 def update
117   - if @comment.update_attributes(params[:comment])
  117 + if @comment.update(params[:comment])
118 118 @plugins.dispatch(:process_extra_comment_params, [@comment,params])
119 119  
120 120 respond_to do |format|
... ...
app/models/certifier.rb
... ... @@ -20,7 +20,7 @@ class Certifier < ActiveRecord::Base
20 20 validates_presence_of :name
21 21  
22 22 def destroy
23   - product_qualifiers.each { |pq| pq.update_attributes! :certifier => nil }
  23 + product_qualifiers.each { |pq| pq.update! :certifier => nil }
24 24 super
25 25 end
26 26  
... ...
app/models/create_community.rb
... ... @@ -30,7 +30,7 @@ class CreateCommunity < Task
30 30 ! DATA_FIELDS.include?(key.to_s)
31 31 end
32 32  
33   - community.update_attributes(community_data)
  33 + community.update(community_data)
34 34 community.image = image if image
35 35 community.environment = self.environment
36 36 community.save!
... ...
app/models/profile.rb
... ... @@ -720,7 +720,7 @@ private :generate_url, :url_options
720 720 num = num + 1
721 721 new_name = original_article.name + ' ' + num.to_s
722 722 end
723   - original_article.update_attributes!(:name => new_name)
  723 + original_article.update!(:name => new_name)
724 724 end
725 725 article_copy = article.copy(:profile => self, :parent => parent, :advertise => false)
726 726 if article.profile.home_page == article
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -15,12 +15,12 @@ Given /^the following users?$/ do |table|
15 15 end
16 16  
17 17 Given /^"(.+)" is (invisible|visible)$/ do |user, visibility|
18   - User.find_by_login(user).person.update_attributes({:visible => (visibility == 'visible')}, :without_protection => true)
  18 + User.find_by_login(user).person.update({:visible => (visibility == 'visible')}, :without_protection => true)
19 19 end
20 20  
21 21 Given /^"(.+)" is (online|offline|busy) in chat$/ do |user, status|
22 22 status = {'online' => 'chat', 'offline' => '', 'busy' => 'dnd'}[status]
23   - User.find_by_login(user).update_attributes(:chat_status => status, :chat_status_at => DateTime.now)
  23 + User.find_by_login(user).update(:chat_status => status, :chat_status_at => DateTime.now)
24 24 end
25 25  
26 26 Given /^the following (community|communities|enterprises?|organizations?)$/ do |kind,table|
... ... @@ -680,7 +680,7 @@ end
680 680 Given /^the article "([^\"]*)" is updated with$/ do |article, table|
681 681 a = Article.find_by_name article
682 682 row = table.hashes.first
683   - a.update_attributes(row)
  683 + a.update(row)
684 684 end
685 685  
686 686 Given /^the cache is turned (on|off)$/ do |state|
... ...
lib/acts_as_having_posts.rb
... ... @@ -28,7 +28,7 @@ module ActsAsHavingPosts
28 28 def feed=(attrs)
29 29 if attrs
30 30 if self.feed
31   - self.feed.update_attributes(attrs)
  31 + self.feed.update(attrs)
32 32 else
33 33 self.feed_attrs = attrs
34 34 end
... ...
plugins/bsc/controllers/bsc_plugin_myprofile_controller.rb
... ... @@ -140,7 +140,7 @@ class BscPluginMyprofileController < MyProfileController
140 140 session[:notice] = _('Could not edit such contract.')
141 141 redirect_to :action => 'manage_contracts'
142 142 end
143   - if request.post? && @contract.update_attributes(params[:contract])
  143 + if request.post? && @contract.update(params[:contract])
144 144  
145 145 # updating associated enterprises
146 146 enterprises_ids = params[:enterprises] || ''
... ... @@ -159,7 +159,7 @@ class BscPluginMyprofileController < MyProfileController
159 159  
160 160 to_keep.each do |sale_attrs|
161 161 sale = @contract.sales.find_by_product_id(sale_attrs[:product_id])
162   - sale.update_attributes!(sale_attrs)
  162 + sale.update!(sale_attrs)
163 163 sales.delete(sale_attrs)
164 164 end
165 165  
... ...
plugins/comment_classification/controllers/admin/comment_classification_plugin_labels_controller.rb
... ... @@ -27,7 +27,7 @@ class CommentClassificationPluginLabelsController < AdminController
27 27 @colors = CommentClassificationPlugin::Label::COLORS
28 28 if request.post?
29 29 begin
30   - @label.update_attributes!(params[:label])
  30 + @label.update!(params[:label])
31 31 session[:notice] = _('Label updated')
32 32 redirect_to :action => :index
33 33 rescue
... ...
plugins/comment_classification/controllers/admin/comment_classification_plugin_status_controller.rb
... ... @@ -25,7 +25,7 @@ class CommentClassificationPluginStatusController < AdminController
25 25 @status = CommentClassificationPlugin::Status.find(params[:id])
26 26 if request.post?
27 27 begin
28   - @status.update_attributes!(params[:status])
  28 + @status.update!(params[:status])
29 29 session[:notice] = _('Status updated')
30 30 redirect_to :action => :index
31 31 rescue
... ...
plugins/comment_classification/controllers/comment_classification_plugin_myprofile_controller.rb
... ... @@ -13,7 +13,7 @@ class CommentClassificationPluginMyprofileController < MyProfileController
13 13 @statuses = CommentClassificationPlugin::Status.enabled
14 14 @status = CommentClassificationPlugin::CommentStatusUser.new(:profile => user, :comment => @comment)
15 15 if request.post? && params[:status]
16   - @status.update_attributes(params[:status])
  16 + @status.update(params[:status])
17 17 @status.save
18 18 end
19 19 end
... ...
plugins/driven_signup/controllers/admin/driven_signup_plugin/admin_controller.rb
... ... @@ -15,7 +15,7 @@ class DrivenSignupPlugin::AdminController < AdminController
15 15 def edit
16 16 @auth = environment.driven_signup_auths.where(id: params[:id]).first
17 17 @auth ||= environment.driven_signup_auths.build
18   - @auth.update_attributes params[:auth]
  18 + @auth.update params[:auth]
19 19 end
20 20  
21 21 def destroy
... ...
plugins/fb_app/controllers/public/fb_app_plugin_page_tab_controller.rb
... ... @@ -68,7 +68,7 @@ class FbAppPluginPageTabController < FbAppPluginController
68 68 if request.put? and @page_id.present?
69 69 create_page_tabs if @page_tab.nil?
70 70  
71   - @page_tab.update_attributes! params[:page_tab]
  71 + @page_tab.update! params[:page_tab]
72 72  
73 73 respond_to do |format|
74 74 format.js{ render action: 'admin' }
... ...
plugins/fb_app/models/fb_app_plugin/page_tab.rb
... ... @@ -27,7 +27,7 @@ class FbAppPlugin::PageTab < ActiveRecord::Base
27 27 page_ids.map do |page_id|
28 28 page_tab = FbAppPlugin::PageTab.where(page_id: page_id).first
29 29 page_tab ||= FbAppPlugin::PageTab.new page_id: page_id
30   - page_tab.update_attributes! attrs
  30 + page_tab.update! attrs
31 31 page_tab
32 32 end
33 33 end
... ...
plugins/lattes_curriculum/lib/lattes_curriculum_plugin.rb
... ... @@ -129,7 +129,7 @@ class LattesCurriculumPlugin < Noosfero::Plugin
129 129  
130 130 def academic_info_transaction
131 131 AcademicInfo.transaction do
132   - context.profile.academic_info.update_attributes!(context.params[:academic_infos])
  132 + context.profile.academic_info.update!(context.params[:academic_infos])
133 133 end
134 134 end
135 135  
... ...
plugins/ldap/controllers/ldap_plugin_admin_controller.rb
... ... @@ -6,7 +6,7 @@ class LdapPluginAdminController < PluginAdminController
6 6 end
7 7  
8 8 def update
9   - if @environment.update_attributes(params[:environment])
  9 + if @environment.update(params[:environment])
10 10 session[:notice] = _('Ldap configuration updated successfully.')
11 11 else
12 12 session[:notice] = _('Ldap configuration could not be saved.')
... ...
plugins/oauth_client/controllers/oauth_client_plugin_admin_controller.rb
... ... @@ -16,7 +16,7 @@ class OauthClientPluginAdminController < AdminController
16 16 def edit
17 17 @provider = params[:id] ? environment.oauth_providers.find(params[:id]) : environment.oauth_providers.new
18 18 if request.post?
19   - if @provider.update_attributes(params['oauth_client_plugin_provider'])
  19 + if @provider.update(params['oauth_client_plugin_provider'])
20 20 session[:notice] = _('Saved!')
21 21 else
22 22 session[:notice] = _('Error!')
... ...
plugins/open_graph/controllers/myprofile/open_graph_plugin/myprofile_controller.rb
... ... @@ -17,7 +17,7 @@ class OpenGraphPlugin::MyprofileController < MyProfileController
17 17 end
18 18  
19 19 def track_config
20   - profile.update_attributes! params[:profile_data]
  20 + profile.update! params[:profile_data]
21 21 render partial: 'track_form', locals: {context: context, reload: true}
22 22 end
23 23  
... ...
plugins/open_graph/test/unit/open_graph_graph/publisher_test.rb
... ... @@ -25,7 +25,7 @@ class OpenGraphPlugin::PublisherTest < ActiveSupport::TestCase
25 25  
26 26 @community = @actor.environment.communities.create! name: 'comm', identifier: 'comm', closed: false
27 27  
28   - @actor.update_attributes!({
  28 + @actor.update!({
29 29 open_graph_settings: {
30 30 activity_track_enabled: "true",
31 31 enterprise_track_enabled: "true",
... ... @@ -43,7 +43,7 @@ class OpenGraphPlugin::PublisherTest < ActiveSupport::TestCase
43 43 open_graph_enterprise_profiles_ids: "#{@enterprise.id}",
44 44 open_graph_community_profiles_ids: "#{@community.id}",
45 45 })
46   - @other_actor.update_attributes! open_graph_settings: { activity_track_enabled: "true", },
  46 + @other_actor.update! open_graph_settings: { activity_track_enabled: "true", },
47 47 open_graph_activity_track_configs_attributes: { 0 => { tracker_id: @other_actor.id, object_type: 'friend', }, }
48 48  
49 49 # active
... ...
plugins/organization_ratings/controllers/organization_ratings_plugin_admin_controller.rb
... ... @@ -8,7 +8,7 @@ class OrganizationRatingsPluginAdminController < PluginAdminController
8 8 end
9 9  
10 10 def update
11   - if env_organization_ratings_config.update_attributes(params[:organization_ratings_config])
  11 + if env_organization_ratings_config.update(params[:organization_ratings_config])
12 12 session[:notice] = _('Configuration updated successfully.')
13 13 else
14 14 session[:notice] = _('Configuration could not be saved.')
... ... @@ -16,4 +16,4 @@ class OrganizationRatingsPluginAdminController < PluginAdminController
16 16 render :action => 'index'
17 17 end
18 18  
19   -end
20 19 \ No newline at end of file
  20 +end
... ...
plugins/piwik/controllers/piwik_plugin_admin_controller.rb
... ... @@ -4,7 +4,7 @@ class PiwikPluginAdminController < PluginAdminController
4 4  
5 5 def index
6 6 if request.post?
7   - if @environment.update_attributes(params[:environment])
  7 + if @environment.update(params[:environment])
8 8 session[:notice] = _('Piwik plugin settings updated successfully.')
9 9 else
10 10 session[:notice] = _('Piwik plugin settings could not be saved.')
... ...
plugins/send_email/controllers/send_email_plugin_admin_controller.rb
... ... @@ -3,7 +3,7 @@ class SendEmailPluginAdminController < PluginsController
3 3 def index
4 4 @environment = environment
5 5 if request.post?
6   - if environment.update_attributes(params[:environment])
  6 + if environment.update(params[:environment])
7 7 session[:notice] = _('Configurations was saved')
8 8 redirect_to :controller => 'plugins'
9 9 else
... ...
plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb
... ... @@ -9,7 +9,7 @@ class SnifferPluginMyprofileController < MyProfileController
9 9 def edit
10 10 if request.post?
11 11 begin
12   - @sniffer_profile.update_attributes(params[:sniffer_plugin_profile])
  12 + @sniffer_profile.update(params[:sniffer_plugin_profile])
13 13 @sniffer_profile.enabled = true
14 14 @sniffer_profile.save!
15 15 session[:notice] = _('Consumer interests updated')
... ...
plugins/tolerance_time/controllers/tolerance_time_plugin_myprofile_controller.rb
... ... @@ -5,7 +5,7 @@ class ToleranceTimePluginMyprofileController < MyProfileController
5 5 if request.post?
6 6 begin
7 7 convert_params
8   - @tolerance.update_attributes!(params[:tolerance])
  8 + @tolerance.update!(params[:tolerance])
9 9 convert_values
10 10 session[:notice] = _('Tolerance updated')
11 11 rescue
... ...
script/apply-template
... ... @@ -46,7 +46,7 @@ when 'active-enterprise'
46 46 active_enterprises.each do |enterprise|
47 47 old_home = enterprise.home_page
48 48 enterprise.apply_template(env.enterprise_template)
49   - enterprise.home_page.update_attributes!(:body => old_home.body)
  49 + enterprise.home_page.update!(:body => old_home.body)
50 50 enterprise.save!
51 51 end
52 52 when 'community'
... ...
test/functional/chat_controller_test.rb
... ... @@ -73,14 +73,14 @@ class ChatControllerTest < ActionController::TestCase
73 73 end
74 74  
75 75 should 'not update presence status from non-ajax requests' do
76   - @person.user.expects(:update_attributes).never
  76 + @person.user.expects(:update).never
77 77 @controller.stubs(:current_user).returns(@person.user)
78 78 get :update_presence_status
79 79 assert_template nil
80 80 end
81 81  
82 82 should 'update presence status from ajax requests' do
83   - @person.user.expects(:update_attributes).once
  83 + @person.user.expects(:update).once
84 84 @controller.stubs(:current_user).returns(@person.user)
85 85 @request.stubs(:xhr?).returns(true)
86 86 get :update_presence_status
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -144,7 +144,7 @@ class ContentViewerControllerTest < ActionController::TestCase
144 144  
145 145 should 'not display forbidden articles' do
146 146 profile.articles.create!(:name => 'test')
147   - profile.update_attributes!({:public_content => false}, :without_protection => true)
  147 + profile.update!({:public_content => false}, :without_protection => true)
148 148  
149 149 Article.any_instance.expects(:display_to?).with(anything).returns(false)
150 150 get :view_page, :profile => profile.identifier, :page => [ 'test' ]
... ... @@ -153,7 +153,7 @@ class ContentViewerControllerTest < ActionController::TestCase
153 153  
154 154 should 'display allowed articles' do
155 155 profile.articles.create!(:name => 'test')
156   - profile.update_attributes!({:public_content => false}, :without_protection => true)
  156 + profile.update!({:public_content => false}, :without_protection => true)
157 157  
158 158 Article.any_instance.expects(:display_to?).with(anything).returns(true)
159 159 get :view_page, :profile => profile.identifier, :page => [ 'test' ]
... ...
test/functional/features_controller_test.rb
... ... @@ -66,7 +66,7 @@ class FeaturesControllerTest < ActionController::TestCase
66 66  
67 67 def test_should_mark_current_organization_approval_method_in_view
68 68 uses_host 'anhetegua.net'
69   - Environment.find(environments(:anhetegua_net).id).update_attributes(:organization_approval_method => :region)
  69 + Environment.find(environments(:anhetegua_net).id).update(:organization_approval_method => :region)
70 70  
71 71 post :index
72 72  
... ...
test/functional/mailconf_controller_test.rb
... ... @@ -60,7 +60,7 @@ class MailconfControllerTest < ActionController::TestCase
60 60  
61 61 should 'display correctly the state false of e-mail enable/disable' do
62 62 login_as('ze')
63   - user.update_attributes!(:enable_email => false)
  63 + user.update!(:enable_email => false)
64 64 get :index, :profile => 'ze'
65 65 assert_tag :tag => 'a', :content => 'Enable e-Mail'
66 66 assert_no_tag :tag => 'a', :content => 'Disable e-Mail', :attributes => { :href => '/myprofile/ze/mailconf/disable' }
... ...
test/functional/maps_controller_test.rb
... ... @@ -51,7 +51,7 @@ class MapsControllerTest < ActionController::TestCase
51 51 end
52 52  
53 53 should 'back when update address fail' do
54   - Profile.any_instance.stubs(:update_attributes!).returns(false)
  54 + Profile.any_instance.stubs(:update!).returns(false)
55 55 post :edit_location, :profile => profile.identifier, :profile_data => { 'address' => 'new address' }
56 56 assert_nil profile.address
57 57 assert_template 'edit_location'
... ...
test/functional/profile_editor_controller_test.rb
... ... @@ -196,7 +196,7 @@ class ProfileEditorControllerTest < ActionController::TestCase
196 196 end
197 197  
198 198 should 'display properly that the profile is non-public' do
199   - profile.update_attributes!(:public_profile => false)
  199 + profile.update!(:public_profile => false)
200 200 get :edit, :profile => profile.identifier
201 201 assert_tag :tag => 'input', :attributes => { :type => 'radio', :checked => 'checked', :name => 'profile_data[public_profile]', :value => 'false' }
202 202 assert_tag :tag => 'input', :attributes => { :type => 'radio', :name => 'profile_data[public_profile]', :value => 'true' }
... ... @@ -227,7 +227,7 @@ class ProfileEditorControllerTest < ActionController::TestCase
227 227  
228 228 should 'back when update community info fail' do
229 229 org = fast_create(Community)
230   - Community.any_instance.expects(:update_attributes!).raises(ActiveRecord::RecordInvalid)
  230 + Community.any_instance.expects(:update!).raises(ActiveRecord::RecordInvalid)
231 231 post :edit, :profile => org.identifier
232 232  
233 233 assert_template 'edit'
... ... @@ -237,7 +237,7 @@ class ProfileEditorControllerTest < ActionController::TestCase
237 237 should 'back when update enterprise info fail' do
238 238 org = fast_create(Enterprise)
239 239  
240   - Enterprise.any_instance.expects(:update_attributes!).raises(ActiveRecord::RecordInvalid)
  240 + Enterprise.any_instance.expects(:update!).raises(ActiveRecord::RecordInvalid)
241 241 post :edit, :profile => org.identifier
242 242 assert_template 'edit'
243 243 assert_response :success
... ... @@ -801,7 +801,7 @@ class ProfileEditorControllerTest < ActionController::TestCase
801 801 end
802 802  
803 803 should 'show profile nickname on title' do
804   - profile.update_attributes(:nickname => 'my nick')
  804 + profile.update(:nickname => 'my nick')
805 805 get :index, :profile => profile.identifier
806 806 assert_tag :tag => 'h1', :attributes => { :class => 'block-title'}, :descendant => {
807 807 :tag => 'span', :attributes => { :class => 'control-panel-title' }, :content => 'my nick'
... ...
test/functional/tasks_controller_test.rb
... ... @@ -123,7 +123,7 @@ class TasksControllerTest < ActionController::TestCase
123 123  
124 124 post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}}
125 125 t.reload
126   -
  126 +
127 127 ok('task should be finished') { t.status == Task::Status::FINISHED }
128 128  
129 129 c.reload
... ... @@ -190,7 +190,7 @@ class TasksControllerTest < ActionController::TestCase
190 190  
191 191 should 'create article with reference_article after finish approve article task' do
192 192 c = fast_create(Community)
193   - c.update_attributes(:moderated_articles => false)
  193 + c.update(:moderated_articles => false)
194 194 @controller.stubs(:profile).returns(c)
195 195 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
196 196 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
... ... @@ -202,7 +202,7 @@ class TasksControllerTest < ActionController::TestCase
202 202  
203 203 should 'create published article in folder after finish approve article task' do
204 204 c = fast_create(Community)
205   - c.update_attributes(:moderated_articles => false)
  205 + c.update(:moderated_articles => false)
206 206 @controller.stubs(:profile).returns(c)
207 207 folder = create(Folder, :profile => c, :name => 'test folder')
208 208 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
... ... @@ -215,7 +215,7 @@ class TasksControllerTest < ActionController::TestCase
215 215  
216 216 should 'be highlighted if asked when approving a published article' do
217 217 c = fast_create(Community)
218   - c.update_attributes(:moderated_articles => false)
  218 + c.update(:moderated_articles => false)
219 219 @controller.stubs(:profile).returns(c)
220 220 folder = create(Article, :profile => c, :name => 'test folder', :type => 'Folder')
221 221 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
... ... @@ -228,7 +228,7 @@ class TasksControllerTest < ActionController::TestCase
228 228  
229 229 should 'create article of same class after choosing root folder on approve article task' do
230 230 c = fast_create(Community)
231   - c.update_attributes(:moderated_articles => false)
  231 + c.update(:moderated_articles => false)
232 232 @controller.stubs(:profile).returns(c)
233 233 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
234 234 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
... ...
test/integration/signup_test.rb
... ... @@ -24,7 +24,7 @@ class SignupTest < ActionDispatch::IntegrationTest
24 24  
25 25 def test_should_require_acceptance_of_terms_for_signup
26 26 env = Environment.default
27   - env.update_attributes(:terms_of_use => 'You agree to not be annoying.')
  27 + env.update(:terms_of_use => 'You agree to not be annoying.')
28 28 env.min_signup_delay = 0
29 29 env.save!
30 30  
... ...
test/unit/block_test.rb
... ... @@ -136,7 +136,7 @@ class BlockTest < ActiveSupport::TestCase
136 136 user = create_user('testinguser').person
137 137 box = fast_create(Box, :owner_id => user.id, :owner_type => 'Profile')
138 138 block = create(Block, :display => 'never', :box_id => box.id)
139   - assert block.update_attributes!(:display => 'always')
  139 + assert block.update!(:display => 'always')
140 140 block.reload
141 141 assert_equal 'always', block.display
142 142 end
... ...
test/unit/certifier_test.rb
... ... @@ -62,7 +62,7 @@ class CertifierTest < ActiveSupport::TestCase
62 62 should 'set qualifier as self-certified when destroyed' do
63 63 pq = mock
64 64 Certifier.any_instance.stubs(:product_qualifiers).returns([pq])
65   - pq.expects(:update_attributes!).with(:certifier => nil)
  65 + pq.expects(:update!).with(:certifier => nil)
66 66 cert = fast_create(Certifier)
67 67 cert.destroy
68 68 end
... ...
test/unit/highlights_block_test.rb
... ... @@ -63,7 +63,7 @@ class HighlightsBlockTest < ActiveSupport::TestCase
63 63 block = HighlightsBlock.create!(:display => 'never').tap do |b|
64 64 b.box = box
65 65 end
66   - assert block.update_attributes!(:display => 'always')
  66 + assert block.update!(:display => 'always')
67 67 block.reload
68 68 assert_equal 'always', block.display
69 69 end
... ...
test/unit/link_list_block_test.rb
... ... @@ -10,7 +10,7 @@ class LinkListBlockTest < ActiveSupport::TestCase
10 10 l = LinkListBlock.new
11 11 assert_respond_to l, :links
12 12 end
13   -
  13 +
14 14 should 'default value of links' do
15 15 l = LinkListBlock.new
16 16 assert_equal [], l.links
... ... @@ -117,7 +117,7 @@ class LinkListBlockTest < ActiveSupport::TestCase
117 117 block = LinkListBlock.new(:display => 'never').tap do |b|
118 118 b.box = box
119 119 end
120   - assert block.update_attributes!(:display => 'always')
  120 + assert block.update!(:display => 'always')
121 121 block.reload
122 122 assert_equal 'always', block.display
123 123 end
... ...
test/unit/my_network_block_test.rb
... ... @@ -31,7 +31,7 @@ class MyNetworkBlockTest < ActiveSupport::TestCase
31 31 user = create_user('testinguser').person
32 32 box = fast_create(Box, :owner_id => user.id)
33 33 block = MyNetworkBlock.create!(:display => 'never', :box => box)
34   - assert block.update_attributes!(:display => 'always')
  34 + assert block.update!(:display => 'always')
35 35 block.reload
36 36 assert_equal 'always', block.display
37 37 end
... ...
test/unit/person_test.rb
... ... @@ -153,7 +153,7 @@ class PersonTest < ActiveSupport::TestCase
153 153 person = create_user('just_another_person').person
154 154 env.affiliate(person, role)
155 155 refute person.is_admin?(env)
156   - role.update_attributes(:permissions => ['view_environment_admin_panel'])
  156 + role.update(:permissions => ['view_environment_admin_panel'])
157 157 person = Person.find(person.id)
158 158 assert person.is_admin?(env)
159 159 end
... ... @@ -164,7 +164,7 @@ class PersonTest < ActiveSupport::TestCase
164 164  
165 165 # role is an admin role
166 166 role = create(Role, :name => 'just_another_admin_role')
167   - role.update_attributes(:permissions => ['view_environment_admin_panel'])
  167 + role.update(:permissions => ['view_environment_admin_panel'])
168 168  
169 169 # user is admin of env1, but not of env2
170 170 person = create_user('just_another_person').person
... ...
test/unit/recent_documents_block_test.rb
... ... @@ -84,7 +84,7 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase
84 84 end
85 85  
86 86 should 'be able to update display setting' do
87   - assert @block.update_attributes!(:display => 'always')
  87 + assert @block.update!(:display => 'always')
88 88 @block.reload
89 89 assert_equal 'always', @block.display
90 90 end
... ...
test/unit/rss_feed_test.rb
... ... @@ -255,7 +255,7 @@ class RssFeedTest < ActiveSupport::TestCase
255 255 should 'include only posts from some language' do
256 256 profile = create_user('testuser').person
257 257 blog = create(Blog, :name => 'blog-test', :profile => profile)
258   - blog.feed.update_attributes! :language => 'es'
  258 + blog.feed.update! :language => 'es'
259 259 blog.posts << en_post = fast_create(TextArticle, :name => "English", :profile_id => profile.id, :parent_id => blog.id, :published => true, :language => 'en')
260 260 blog.posts << es_post = fast_create(TextArticle, :name => "Spanish", :profile_id => profile.id, :parent_id => blog.id, :published => true, :language => 'es')
261 261  
... ...
test/unit/user_test.rb
... ... @@ -43,12 +43,12 @@ class UserTest &lt; ActiveSupport::TestCase
43 43 end
44 44  
45 45 def test_should_reset_password
46   - users(:johndoe).update_attributes(:password => 'new password', :password_confirmation => 'new password')
  46 + users(:johndoe).update(:password => 'new password', :password_confirmation => 'new password')
47 47 assert_equal users(:johndoe), User.authenticate('johndoe', 'new password')
48 48 end
49 49  
50 50 def test_should_not_rehash_password
51   - users(:johndoe).update_attributes(:login => 'johndoe2')
  51 + users(:johndoe).update(:login => 'johndoe2')
52 52 assert_equal users(:johndoe), User.authenticate('johndoe2', 'test')
53 53 end
54 54  
... ...
vendor/plugins/action_tracker/lib/action_tracker_model.rb
... ... @@ -37,7 +37,7 @@ module ActionTracker
37 37 target_hash = params[:target].nil? ? {} : {:target_type => params[:target].class.base_class.to_s, :target_id => params[:target].id}
38 38 conditions = { :user_id => u.id, :user_type => u.class.base_class.to_s, :verb => params[:verb].to_s }.merge(target_hash)
39 39 l = where(conditions).last
40   - ( !l.nil? and Time.now - l.updated_at < ActionTrackerConfig.timeout ) ? l.update_attributes(params.merge({ :updated_at => Time.now })) : l = new(params)
  40 + ( !l.nil? and Time.now - l.updated_at < ActionTrackerConfig.timeout ) ? l.update(params.merge({ :updated_at => Time.now })) : l = new(params)
41 41 l
42 42 end
43 43  
... ... @@ -48,7 +48,7 @@ module ActionTracker
48 48 l = where({user_id: u.id, user_type: u.class.base_class.to_s, verb: params[:verb].to_s}.merge target_hash).last
49 49 if !l.nil? and Time.now - l.created_at < ActionTrackerConfig.timeout
50 50 params[:params].clone.each { |key, value| params[:params][key] = l.params[key].clone.push(value) }
51   - l.update_attributes params
  51 + l.update params
52 52 else
53 53 params[:params].clone.each { |key, value| params[:params][key] = [value] }
54 54 l = new params
... ...
vendor/plugins/kandadaboggu-vote_fu/examples/voteables_controller.rb
... ... @@ -42,7 +42,7 @@ class VoteablesController &lt; ApplicationController
42 42 end
43 43  
44 44 # GET /users/:id/voteables/1/edit
45   - def edit
  45 + def edit
46 46 @voteable ||= Voteable.find(params[:id])
47 47 end
48 48  
... ... @@ -51,7 +51,7 @@ class VoteablesController &lt; ApplicationController
51 51 def create
52 52 @voteable = Voteable.new(params[:voteable])
53 53 @voteable.user = current_user
54   -
  54 +
55 55 respond_to do |format|
56 56 if @voteable.save
57 57 flash[:notice] = 'Voteable was successfully saved.'
... ... @@ -68,9 +68,9 @@ class VoteablesController &lt; ApplicationController
68 68 # PUT /users/:id/voteable/1.xml
69 69 def update
70 70 @voteable = Voteable.find(params[:id])
71   -
  71 +
72 72 respond_to do |format|
73   - if @quote.update_attributes(params[:voteable])
  73 + if @quote.update(params[:voteable])
74 74 flash[:notice] = 'Voteable was successfully updated.'
75 75 format.html { redirect_to([@user, @voteable]) }
76 76 format.xml { head :ok }
... ... @@ -92,17 +92,17 @@ class VoteablesController &lt; ApplicationController
92 92 format.xml { head :ok }
93 93 end
94 94 end
95   -
  95 +
96 96 private
97   - def find_user
  97 + def find_user
98 98 @user = User.find(params[:user_id])
99 99 end
100   -
  100 +
101 101 def must_own_voteable
102 102 @voteable ||= Voteable.find(params[:id])
103 103 @voteable.user == current_user || ownership_violation
104 104 end
105   -
  105 +
106 106 def ownership_violation
107 107 respond_to do |format|
108 108 flash[:notice] = 'You cannot edit or delete voteable that you do not own!'
... ... @@ -111,7 +111,7 @@ class VoteablesController &lt; ApplicationController
111 111 end
112 112 end
113 113 end
114   -
115   -
116   -
  114 +
  115 +
  116 +
117 117 end
... ...
vendor/plugins/kandadaboggu-vote_fu/lib/controllers/votes_controller.rb
1 1 class VotesController < ApplicationController
2 2 # First, figure out our nested scope. User or vote?
3 3 # before_filter :find_my_scope
4   -
  4 +
5 5 # before_filter :find_user
6   -
  6 +
7 7 # before_filter :login_required, :only => [:new, :edit, :destroy, :create, :update]
8 8 # before_filter :must_own_vote, :only => [:edit, :destroy, :update]
9 9  
... ... @@ -70,7 +70,7 @@ class VotesController &lt; ApplicationController
70 70 @vote = Vote.find(params[:id])
71 71  
72 72 respond_to do |format|
73   - if @vote.update_attributes(params[:vote])
  73 + if @vote.update(params[:vote])
74 74 flash[:notice] = 'Vote was successfully updated.'
75 75 format.html { redirect_to([@user, @vote]) }
76 76 format.xml { head :ok }
... ...