diff --git a/.gitignore b/.gitignore
index 74399f663..fea147b0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,12 @@ public/404.html
public/422.html
public/500.html
+# the db/schema.rb. Although this is contrary to rails best-practises, we
+# cannot provide a schema.rb that works for both MySQL and PostgreSQL, so we
+# have no choice. Our migrations are maintained, so it should always be
+# possible to get back to a "clean" database schema anyway.
+db/schema.rb
+
# Sprites
app/assets/images/branding-*.png
app/assets/images/branding/logos-*.png
diff --git a/Changelog.md b/Changelog.md
index 9ad30f2bc..bd1fc24a7 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -28,6 +28,7 @@ If so, please delete it since it will prevent the federation from working proper
* Update the user data export archive format [#6726](https://github.com/diaspora/diaspora/pull/6726)
* Use id as fallback when sorting posts [#7523](https://github.com/diaspora/diaspora/pull/7523)
* Remove no-posts-info when adding posts to the stream [#7523](https://github.com/diaspora/diaspora/pull/7523)
+* Upgrade to rails 5.1 [#7514](https://github.com/diaspora/diaspora/pull/7514)
## Bug fixes
diff --git a/Gemfile b/Gemfile
index fc47ba744..8fcd22e75 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
source "https://rubygems.org"
-gem "rails", "4.2.9"
+gem "rails", "5.1.3"
# Legacy Rails features, remove me!
# responders (class level)
@@ -90,7 +90,7 @@ gem "entypo-rails", "3.0.0"
gem "handlebars_assets", "0.23.2"
gem "jquery-rails", "4.3.1"
gem "js-routes", "1.3.3"
-gem "js_image_paths", "0.1.0"
+gem "js_image_paths", "0.1.1"
source "https://rails-assets.org" do
gem "rails-assets-jquery", "3.2.1" # Should be kept in sync with jquery-rails
@@ -124,7 +124,7 @@ end
gem "http_accept_language", "2.1.1"
gem "i18n-inflector-rails", "1.0.7"
-gem "rails-i18n", "4.0.9"
+gem "rails-i18n", "5.0.4"
# Mail
@@ -185,7 +185,7 @@ gem "typhoeus", "1.1.2"
gem "gon", "6.1.0"
gem "hamlit", "2.8.4"
-gem "mobile-fu", "1.3.1"
+gem "mobile_fu", "1.4.0"
gem "rails-timeago", "2.16.0"
gem "will_paginate", "3.1.6"
@@ -280,7 +280,6 @@ group :test do
gem "fuubar", "2.2.0"
gem "json-schema-rspec", "0.0.4"
gem "rspec-json_expectations", "~> 2.1"
- gem "test_after_commit", "1.1.0"
# Cucumber (integration tests)
@@ -315,4 +314,7 @@ group :development, :test do
gem "jasmine-jquery-rails", "2.0.3"
gem "rails-assets-jasmine-ajax", "3.3.1", source: "https://rails-assets.org"
gem "sinon-rails", "1.15.0"
+
+ # For `assigns` in controller specs
+ gem "rails-controller-testing", "1.0.2"
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 85a208bf6..5ed511fe9 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -2,44 +2,47 @@ GEM
remote: https://rubygems.org/
remote: https://rails-assets.org/
specs:
- actionmailer (4.2.9)
- actionpack (= 4.2.9)
- actionview (= 4.2.9)
- activejob (= 4.2.9)
+ actioncable (5.1.3)
+ actionpack (= 5.1.3)
+ nio4r (~> 2.0)
+ websocket-driver (~> 0.6.1)
+ actionmailer (5.1.3)
+ actionpack (= 5.1.3)
+ actionview (= 5.1.3)
+ activejob (= 5.1.3)
mail (~> 2.5, >= 2.5.4)
- rails-dom-testing (~> 1.0, >= 1.0.5)
- actionpack (4.2.9)
- actionview (= 4.2.9)
- activesupport (= 4.2.9)
- rack (~> 1.6)
- rack-test (~> 0.6.2)
- rails-dom-testing (~> 1.0, >= 1.0.5)
+ rails-dom-testing (~> 2.0)
+ actionpack (5.1.3)
+ actionview (= 5.1.3)
+ activesupport (= 5.1.3)
+ rack (~> 2.0)
+ rack-test (~> 0.6.3)
+ rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
- actionview (4.2.9)
- activesupport (= 4.2.9)
+ actionview (5.1.3)
+ activesupport (= 5.1.3)
builder (~> 3.1)
- erubis (~> 2.7.0)
- rails-dom-testing (~> 1.0, >= 1.0.5)
+ erubi (~> 1.4)
+ rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.9.7)
activemodel (>= 3.2)
concurrent-ruby (~> 1.0)
- activejob (4.2.9)
- activesupport (= 4.2.9)
- globalid (>= 0.3.0)
- activemodel (4.2.9)
- activesupport (= 4.2.9)
- builder (~> 3.1)
- activerecord (4.2.9)
- activemodel (= 4.2.9)
- activesupport (= 4.2.9)
- arel (~> 6.0)
+ activejob (5.1.3)
+ activesupport (= 5.1.3)
+ globalid (>= 0.3.6)
+ activemodel (5.1.3)
+ activesupport (= 5.1.3)
+ activerecord (5.1.3)
+ activemodel (= 5.1.3)
+ activesupport (= 5.1.3)
+ arel (~> 8.0)
activerecord-import (0.19.1)
activerecord (>= 3.2)
- activesupport (4.2.9)
+ activesupport (5.1.3)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
- thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
acts-as-taggable-on (5.0.0)
activerecord (>= 4.2.8)
@@ -49,7 +52,7 @@ GEM
rack (>= 1.1.0)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
- arel (6.0.4)
+ arel (8.0.0)
asset_sync (2.2.0)
activemodel (>= 4.1.0)
fog-core
@@ -183,7 +186,7 @@ GEM
entypo-rails (3.0.0)
railties (>= 4.1, < 6)
equalizer (0.0.11)
- erubis (2.7.0)
+ erubi (1.6.1)
eslintrb (2.1.0)
execjs
multi_json (>= 1.3)
@@ -324,8 +327,9 @@ GEM
js-routes (1.3.3)
railties (>= 3.2)
sprockets-rails
- js_image_paths (0.1.0)
- rails (~> 4.0)
+ js_image_paths (0.1.1)
+ rails (>= 4.0, < 6.0)
+ sprockets (>= 3.0.0)
json (2.1.0)
json-jwt (1.7.2)
activesupport
@@ -371,7 +375,7 @@ GEM
mini_magick (4.8.0)
mini_portile2 (2.2.0)
minitest (5.10.3)
- mobile-fu (1.3.1)
+ mobile_fu (1.4.0)
rack-mobile-detect
rails
multi_json (1.12.1)
@@ -430,7 +434,7 @@ GEM
validate_url
webfinger (>= 1.0.1)
orm_adapter (0.5.0)
- parallel (1.11.2)
+ parallel (1.12.0)
parser (2.4.0.0)
ast (~> 2.2)
pg (0.21.0)
@@ -467,7 +471,7 @@ GEM
byebug (~> 9.0)
pry (~> 0.10)
public_suffix (2.0.5)
- rack (1.6.8)
+ rack (2.0.3)
rack-cors (1.0.1)
rack-google-analytics (1.2.0)
actionpack
@@ -488,17 +492,18 @@ GEM
rack
rack-test (0.6.3)
rack (>= 1.0)
- rails (4.2.9)
- actionmailer (= 4.2.9)
- actionpack (= 4.2.9)
- actionview (= 4.2.9)
- activejob (= 4.2.9)
- activemodel (= 4.2.9)
- activerecord (= 4.2.9)
- activesupport (= 4.2.9)
- bundler (>= 1.3.0, < 2.0)
- railties (= 4.2.9)
- sprockets-rails
+ rails (5.1.3)
+ actioncable (= 5.1.3)
+ actionmailer (= 5.1.3)
+ actionpack (= 5.1.3)
+ actionview (= 5.1.3)
+ activejob (= 5.1.3)
+ activemodel (= 5.1.3)
+ activerecord (= 5.1.3)
+ activesupport (= 5.1.3)
+ bundler (>= 1.3.0)
+ railties (= 5.1.3)
+ sprockets-rails (>= 2.0.0)
rails-assets-autosize (4.0.0)
rails-assets-backbone (1.3.3)
rails-assets-underscore (>= 1.8.3)
@@ -545,23 +550,25 @@ GEM
rails-assets-markdown-it-sup (1.0.0)
rails-assets-perfect-scrollbar (0.6.16)
rails-assets-underscore (1.8.3)
- rails-deprecated_sanitizer (1.0.3)
- activesupport (>= 4.2.0.alpha)
- rails-dom-testing (1.0.8)
- activesupport (>= 4.2.0.beta, < 5.0)
- nokogiri (~> 1.6)
- rails-deprecated_sanitizer (>= 1.0.1)
+ rails-controller-testing (1.0.2)
+ actionpack (~> 5.x, >= 5.0.1)
+ actionview (~> 5.x, >= 5.0.1)
+ activesupport (~> 5.x)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
- rails-i18n (4.0.9)
+ rails-i18n (5.0.4)
i18n (~> 0.7)
- railties (~> 4.0)
+ railties (~> 5.0)
rails-timeago (2.16.0)
actionpack (>= 3.1)
activesupport (>= 3.1)
- railties (4.2.9)
- actionpack (= 4.2.9)
- activesupport (= 4.2.9)
+ railties (5.1.3)
+ actionpack (= 5.1.3)
+ activesupport (= 5.1.3)
+ method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
@@ -682,8 +689,6 @@ GEM
tins (~> 1.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
- test_after_commit (1.1.0)
- activerecord (>= 3.2)
thor (0.19.1)
thread_safe (0.3.6)
tilt (2.0.8)
@@ -803,7 +808,7 @@ DEPENDENCIES
jasmine-jquery-rails (= 2.0.3)
jquery-rails (= 4.3.1)
js-routes (= 1.3.3)
- js_image_paths (= 0.1.0)
+ js_image_paths (= 0.1.1)
json (= 2.1.0)
json-schema (= 2.8.0)
json-schema-rspec (= 0.0.4)
@@ -812,7 +817,7 @@ DEPENDENCIES
markerb (= 1.1.0)
mini_magick (= 4.8.0)
minitest
- mobile-fu (= 1.3.1)
+ mobile_fu (= 1.4.0)
mysql2 (= 0.4.8)
nokogiri (= 1.8.0)
omniauth (= 1.6.1)
@@ -836,7 +841,7 @@ DEPENDENCIES
rack-piwik (= 0.3.0)
rack-rewrite (= 1.5.1)
rack-ssl (= 1.4.1)
- rails (= 4.2.9)
+ rails (= 5.1.3)
rails-assets-autosize (= 4.0.0)!
rails-assets-backbone (= 1.3.3)!
rails-assets-blueimp-gallery (= 2.25.2)!
@@ -859,7 +864,8 @@ DEPENDENCIES
rails-assets-markdown-it-sub (= 1.0.0)!
rails-assets-markdown-it-sup (= 1.0.0)!
rails-assets-perfect-scrollbar (= 0.6.16)!
- rails-i18n (= 4.0.9)
+ rails-controller-testing (= 1.0.2)
+ rails-i18n (= 5.0.4)
rails-timeago (= 2.16.0)
rb-fsevent (= 0.10.2)
rb-inotify (= 0.9.10)
@@ -883,7 +889,6 @@ DEPENDENCIES
spring-commands-rspec (= 1.0.4)
sprockets-rails (= 3.2.0)
string-direction (= 1.2.0)
- test_after_commit (= 1.1.0)
thor (= 0.19.1)
timecop (= 0.9.1)
turbo_dev_assets (= 0.0.2)
diff --git a/app/assets/javascripts/mobile/mobile_file_uploader.js b/app/assets/javascripts/mobile/mobile_file_uploader.js
index 86c784818..3a33ef5ee 100644
--- a/app/assets/javascripts/mobile/mobile_file_uploader.js
+++ b/app/assets/javascripts/mobile/mobile_file_uploader.js
@@ -33,7 +33,6 @@ function createUploader(){
$("#fileInfo-publisher").text(fileName + " " + progress + "%");
},
onSubmit: function() {
- $("#file-upload-publisher").addClass("loading");
$("#publisher_textarea_wrapper").addClass("with_attachments");
$("#photodropzone").append(
"
" +
diff --git a/app/assets/stylesheets/bootstrap-complete.scss b/app/assets/stylesheets/bootstrap-complete.scss
index df03c6ad0..0e49df681 100644
--- a/app/assets/stylesheets/bootstrap-complete.scss
+++ b/app/assets/stylesheets/bootstrap-complete.scss
@@ -1,7 +1,7 @@
// Calling this file bootstrap would cause an infinite recursion during asset compilation.
@import "bootstrap-sprockets";
@import "bootstrap-variables"; //our overwrites of bootstrap variables
-@import "bootstrap";
+@import "_bootstrap";
// Plugins
diff --git a/app/controllers/admin/admin_controller.rb b/app/controllers/admin/admin_controller.rb
index 8e22795ef..24f08cdf0 100644
--- a/app/controllers/admin/admin_controller.rb
+++ b/app/controllers/admin/admin_controller.rb
@@ -1,8 +1,6 @@
module Admin
class AdminController < ApplicationController
-
- before_filter :authenticate_user!
- before_filter :redirect_unless_admin
-
+ before_action :authenticate_user!
+ before_action :redirect_unless_admin
end
end
diff --git a/app/controllers/api/openid_connect/authorizations_controller.rb b/app/controllers/api/openid_connect/authorizations_controller.rb
index cc2e6a0a6..94f268010 100644
--- a/app/controllers/api/openid_connect/authorizations_controller.rb
+++ b/app/controllers/api/openid_connect/authorizations_controller.rb
@@ -205,7 +205,7 @@ module Api
if prompt && prompt.include?("none")
handle_prompt_none
elsif prompt && prompt.include?("login")
- new_params = params.except("controller", "action").merge(prompt: prompt.remove("login"))
+ new_params = params.except("controller", "action").permit!.to_h.merge(prompt: prompt.remove("login"))
reauthenticate(new_params)
else
authenticate_user!
diff --git a/app/controllers/api/openid_connect/token_endpoint_controller.rb b/app/controllers/api/openid_connect/token_endpoint_controller.rb
index c8fd53c2d..378f0086b 100644
--- a/app/controllers/api/openid_connect/token_endpoint_controller.rb
+++ b/app/controllers/api/openid_connect/token_endpoint_controller.rb
@@ -8,7 +8,8 @@ module Api
if req["client_assertion_type"] == "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
handle_jwt_bearer(req)
end
- self.status, response.headers, self.response_body = Api::OpenidConnect::TokenEndpoint.new.call(request.env)
+ self.status, headers, self.response_body = Api::OpenidConnect::TokenEndpoint.new.call(request.env)
+ headers.each {|name, value| response.headers[name] = value }
nil
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 50484821e..27e793c1b 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -5,7 +5,7 @@
class ApplicationController < ActionController::Base
before_action :force_tablet_html
has_mobile_fu
- protect_from_forgery except: :receive, with: :exception
+ protect_from_forgery except: :receive, with: :exception, prepend: true
rescue_from ActionController::InvalidAuthenticityToken do
if user_signed_in?
diff --git a/app/controllers/aspect_memberships_controller.rb b/app/controllers/aspect_memberships_controller.rb
index 68215bc37..2bfd0c933 100644
--- a/app/controllers/aspect_memberships_controller.rb
+++ b/app/controllers/aspect_memberships_controller.rb
@@ -6,7 +6,7 @@
class AspectMembershipsController < ApplicationController
before_action :authenticate_user!
- respond_to :html, :json
+ respond_to :json
def destroy
aspect = current_user.aspects.joins(:aspect_memberships).where(aspect_memberships: {id: params[:id]}).first
@@ -30,18 +30,9 @@ class AspectMembershipsController < ApplicationController
if success
render json: AspectMembershipPresenter.new(membership).base_hash
else
- render text: membership.errors.full_messages, status: 403
+ render plain: membership.errors.full_messages, status: 403
end
end
-
- format.all do
- if success
- flash.now[:notice] = I18n.t "aspect_memberships.destroy.success"
- else
- flash.now[:error] = I18n.t "aspect_memberships.destroy.failure"
- end
- redirect_to :back
- end
end
end
@@ -58,35 +49,25 @@ class AspectMembershipsController < ApplicationController
AspectMembership.where(contact_id: @contact.id, aspect_id: @aspect.id).first)
.base_hash
end
-
- format.all do
- flash.now[:notice] = I18n.t("aspects.add_to_aspect.success")
- redirect_to :back
- end
end
else
respond_to do |format|
format.json do
- render text: I18n.t("aspects.add_to_aspect.failure"), status: 409
- end
-
- format.all do
- flash.now[:error] = I18n.t("aspects.add_to_aspect.failure")
- render nothing: true, status: 409
+ render plain: I18n.t("aspects.add_to_aspect.failure"), status: 409
end
end
end
end
rescue_from ActiveRecord::StatementInvalid do
- render text: I18n.t("aspect_memberships.destroy.invalid_statement"), status: 400
+ render plain: I18n.t("aspect_memberships.destroy.invalid_statement"), status: 400
end
rescue_from ActiveRecord::RecordNotFound do
- render text: I18n.t("aspect_memberships.destroy.no_membership"), status: 404
+ render plain: I18n.t("aspect_memberships.destroy.no_membership"), status: 404
end
rescue_from Diaspora::NotMine do
- render text: I18n.t("aspect_memberships.destroy.forbidden"), status: 403
+ render plain: I18n.t("aspect_memberships.destroy.forbidden"), status: 403
end
end
diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb
index ce21bd95d..73bdf8cd2 100644
--- a/app/controllers/aspects_controller.rb
+++ b/app/controllers/aspects_controller.rb
@@ -22,7 +22,7 @@ class AspectsController < ApplicationController
render json: result
else
- render nothing: true, status: 422
+ head :unprocessable_entity
end
end
@@ -71,7 +71,7 @@ class AspectsController < ApplicationController
params[:ordered_aspect_ids].each_with_index do |id, i|
current_user.aspects.find(id).update_attributes(order_id: i)
end
- render nothing: true
+ head :no_content
end
def toggle_chat_privilege
@@ -79,7 +79,7 @@ class AspectsController < ApplicationController
@aspect.chat_enabled = !@aspect.chat_enabled
@aspect.save
- render :nothing => true
+ head :no_content
end
def toggle_contact_visibility
@@ -91,7 +91,7 @@ class AspectsController < ApplicationController
@aspect.contacts_visible = true
end
@aspect.save
- render :nothing => true
+ head :no_content
end
private
diff --git a/app/controllers/blocks_controller.rb b/app/controllers/blocks_controller.rb
index dd5cb4ae9..aa8f43cbb 100644
--- a/app/controllers/blocks_controller.rb
+++ b/app/controllers/blocks_controller.rb
@@ -1,34 +1,23 @@
class BlocksController < ApplicationController
before_action :authenticate_user!
- respond_to :html, :json
+ respond_to :json
def create
block = current_user.blocks.new(block_params)
- if block.save
- disconnect_if_contact(block.person)
- notice = {:notice => t('blocks.create.success')}
- else
- notice = {:error => t('blocks.create.failure')}
- end
+ disconnect_if_contact(block.person) if block.save
respond_with do |format|
- format.html{ redirect_to :back, notice }
- format.json{ render :nothing => true, :status => 204 }
+ format.json { head :no_content }
end
end
def destroy
- if current_user.blocks.find(params[:id]).delete
- notice = {:notice => t('blocks.destroy.success')}
- else
- notice = {:error => t('blocks.destroy.failure')}
- end
+ current_user.blocks.find(params[:id]).delete
respond_with do |format|
- format.html{ redirect_to :back, notice }
- format.json{ render :nothing => true, :status => 204 }
+ format.json { head :no_content }
end
end
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index bde3e2fbb..f9d4ad47d 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -8,21 +8,21 @@ class CommentsController < ApplicationController
respond_to :html, :mobile, :json
rescue_from ActiveRecord::RecordNotFound do
- render nothing: true, status: 404
+ head :not_found
end
def create
begin
comment = comment_service.create(params[:post_id], params[:text])
rescue ActiveRecord::RecordNotFound
- render text: I18n.t("comments.create.error"), status: 404
+ render plain: I18n.t("comments.create.error"), status: 404
return
end
if comment
respond_create_success(comment)
else
- render text: I18n.t("comments.create.error"), status: 422
+ render plain: I18n.t("comments.create.error"), status: 422
end
end
@@ -57,24 +57,24 @@ class CommentsController < ApplicationController
def respond_create_success(comment)
respond_to do |format|
format.json { render json: CommentPresenter.new(comment), status: 201 }
- format.html { render nothing: true, status: 201 }
+ format.html { head :created }
format.mobile { render partial: "comment", locals: {comment: comment} }
end
end
def respond_destroy_success
respond_to do |format|
- format.mobile { redirect_to :back }
- format.js { render nothing: true, status: 204 }
- format.json { render nothing: true, status: 204 }
+ format.mobile { redirect_back fallback_location: stream_path }
+ format.js { head :no_content }
+ format.json { head :no_content }
end
end
def respond_destroy_error
respond_to do |format|
- format.mobile { redirect_to :back }
- format.js { render nothing: true, status: 403 }
- format.json { render nothing: true, status: 403 }
+ format.mobile { redirect_back fallback_location: stream_path }
+ format.js { head :forbidden }
+ format.json { head :forbidden }
end
end
end
diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb
index c69b6d7d8..3f1977655 100644
--- a/app/controllers/conversations_controller.rb
+++ b/app/controllers/conversations_controller.rb
@@ -39,7 +39,7 @@ class ConversationsController < ApplicationController
end
unless person_ids.present?
- render text: I18n.t("javascripts.conversation.create.no_recipient"), status: 422
+ render plain: I18n.t("javascripts.conversation.create.no_recipient"), status: 422
return
end
@@ -53,7 +53,7 @@ class ConversationsController < ApplicationController
flash[:notice] = I18n.t("conversations.create.sent")
render json: {id: @conversation.id}
else
- render text: I18n.t("conversations.create.fail"), status: 422
+ render plain: I18n.t("conversations.create.fail"), status: 422
end
end
@@ -82,7 +82,7 @@ class ConversationsController < ApplicationController
@conversation.set_read(current_user)
render partial: "conversations/show", locals: {conversation: @conversation}
else
- render nothing: true, status: 404
+ head :not_found
end
end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 3c4a6b5ee..74c2b6532 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -33,7 +33,7 @@ class HomeController < ApplicationController
def toggle_mobile
session[:mobile_view] = session[:mobile_view].nil? ? true : !session[:mobile_view]
- redirect_to :back
+ redirect_back fallback_location: root_path
end
def force_mobile
diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb
index 66653e83e..04927022c 100644
--- a/app/controllers/invitations_controller.rb
+++ b/app/controllers/invitations_controller.rb
@@ -42,7 +42,7 @@ class InvitationsController < ApplicationController
t("invitations.create.rejected", emails: invalid_emails.join(", "))
end
- redirect_to :back
+ redirect_back fallback_location: stream_path
end
private
@@ -55,7 +55,7 @@ class InvitationsController < ApplicationController
else
t("invitations.create.closed")
end
- redirect_to :back
+ redirect_back fallback_location: stream_path
end
def valid_email?(email)
@@ -71,6 +71,6 @@ class InvitationsController < ApplicationController
end
def inviter_params
- params.require(:email_inviter).permit(:message, :locale, :emails)
+ params.require(:email_inviter).permit(:message, :locale, :emails).to_h
end
end
diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb
index 20fe1dd69..182760951 100644
--- a/app/controllers/likes_controller.rb
+++ b/app/controllers/likes_controller.rb
@@ -13,10 +13,10 @@ class LikesController < ApplicationController
def create
like = like_service.create(params[:post_id])
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
- render text: I18n.t("likes.create.error"), status: 422
+ render plain: I18n.t("likes.create.error"), status: 422
else
respond_to do |format|
- format.html { render nothing: true, status: 201 }
+ format.html { head :created }
format.mobile { redirect_to post_path(like.post_id) }
format.json { render json: like.as_api_response(:backbone), status: 201 }
end
@@ -24,9 +24,9 @@ class LikesController < ApplicationController
def destroy
if like_service.destroy(params[:id])
- render nothing: true, status: 204
+ head :no_content
else
- render text: I18n.t("likes.destroy.error"), status: 404
+ render plain: I18n.t("likes.destroy.error"), status: 404
end
end
diff --git a/app/controllers/participations_controller.rb b/app/controllers/participations_controller.rb
index 95e8a2c03..1cb9b7b40 100644
--- a/app/controllers/participations_controller.rb
+++ b/app/controllers/participations_controller.rb
@@ -5,9 +5,9 @@ class ParticipationsController < ApplicationController
post = current_user.find_visible_shareable_by_id(Post, params[:post_id])
if post
current_user.participate! post
- render nothing: true, status: :created
+ head :created
else
- render nothing: true, status: :forbidden
+ head :forbidden
end
end
@@ -15,9 +15,9 @@ class ParticipationsController < ApplicationController
participation = current_user.participations.find_by target_id: params[:post_id]
if participation
participation.destroy
- render nothing: true, status: :ok
+ head :ok
else
- render nothing: true, status: :unprocessable_entity
+ head :unprocessable_entity
end
end
end
diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb
index 930ed0b7c..f42a4d908 100644
--- a/app/controllers/people_controller.rb
+++ b/app/controllers/people_controller.rb
@@ -19,8 +19,8 @@ class PeopleController < ApplicationController
rescue_from Diaspora::AccountClosed do
respond_to do |format|
- format.any { redirect_to :back, :notice => t("people.show.closed_account") }
- format.json { render :nothing => true, :status => 410 } # 410 GONE
+ format.any { redirect_back fallback_location: root_path, notice: t("people.show.closed_account") }
+ format.json { head :gone }
end
end
@@ -115,15 +115,15 @@ class PeopleController < ApplicationController
def retrieve_remote
if params[:diaspora_handle]
Workers::FetchWebfinger.perform_async(params[:diaspora_handle])
- render :nothing => true
+ head :ok
else
- render :nothing => true, :status => 422
+ head :unprocessable_entity
end
end
def contacts
respond_to do |format|
- format.json { render nothing: true, status: 406 }
+ format.json { head :not_acceptable }
format.any do
@person = Person.find_by_guid(params[:person_id])
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index d8b59fb4a..a95fdb420 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -66,10 +66,10 @@ class PhotosController < ApplicationController
:status => 201}
end
else
- render :nothing => true, :status => 422
+ head :unprocessable_entity
end
else
- render :nothing => true, :status => 422
+ head :unprocessable_entity
end
end
@@ -80,7 +80,7 @@ class PhotosController < ApplicationController
current_user.retract(photo)
respond_to do |format|
- format.json{ render :nothing => true, :status => 204 }
+ format.json { head :no_content }
format.html do
flash[:notice] = I18n.t 'photos.destroy.notice'
if StatusMessage.find_by_guid(photo.status_message_guid)
@@ -125,27 +125,28 @@ class PhotosController < ApplicationController
end
def legacy_create
- if params[:photo][:aspect_ids] == "all"
- params[:photo][:aspect_ids] = current_user.aspects.collect { |x| x.id }
- elsif params[:photo][:aspect_ids].is_a?(Hash)
- params[:photo][:aspect_ids] = params[:photo][:aspect_ids].values
+ photo_params = params.require(:photo).permit(:pending, :set_profile_photo, aspect_ids: [])
+ if photo_params[:aspect_ids] == "all"
+ photo_params[:aspect_ids] = current_user.aspects.map(&:id)
+ elsif photo_params[:aspect_ids].is_a?(Hash)
+ photo_params[:aspect_ids] = params[:photo][:aspect_ids].values
end
- params[:photo][:user_file] = file_handler(params)
+ photo_params[:user_file] = file_handler(params)
- @photo = current_user.build_post(:photo, params[:photo])
+ @photo = current_user.build_post(:photo, photo_params)
if @photo.save
unless @photo.pending
unless @photo.public?
- aspects = current_user.aspects_from_ids(params[:photo][:aspect_ids])
+ aspects = current_user.aspects_from_ids(photo_params[:aspect_ids])
current_user.add_to_streams(@photo, aspects)
end
- current_user.dispatch_post(@photo, :to => params[:photo][:aspect_ids])
+ current_user.dispatch_post(@photo, to: photo_params[:aspect_ids])
end
- if params[:photo][:set_profile_photo]
+ if photo_params[:set_profile_photo]
profile_params = {:image_url => @photo.url(:thumb_large),
:image_url_medium => @photo.url(:thumb_medium),
:image_url_small => @photo.url(:thumb_small)}
diff --git a/app/controllers/poll_participations_controller.rb b/app/controllers/poll_participations_controller.rb
index 2fd07c76e..a8b874fca 100644
--- a/app/controllers/poll_participations_controller.rb
+++ b/app/controllers/poll_participations_controller.rb
@@ -1,20 +1,17 @@
class PollParticipationsController < ApplicationController
- include ApplicationHelper
- before_filter :authenticate_user!
+ before_action :authenticate_user!
def create
answer = PollAnswer.find(params[:poll_answer_id])
poll_participation = current_user.participate_in_poll!(target, answer) if target
respond_to do |format|
- format.html { redirect_to :back }
format.mobile { redirect_to stream_path }
format.json { render json: poll_participation, :status => 201 }
end
rescue ActiveRecord::RecordInvalid
respond_to do |format|
- format.html { redirect_to :back }
format.mobile { redirect_to stream_path }
- format.json { render :nothing => true, :status => 403 }
+ format.json { head :forbidden }
end
end
@@ -25,4 +22,4 @@ class PollParticipationsController < ApplicationController
current_user.find_visible_shareable_by_id(Post, params[:post_id]) || raise(ActiveRecord::RecordNotFound.new)
end
end
-end
\ No newline at end of file
+end
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 6435ed3ad..8b5386d2b 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -13,7 +13,7 @@ class PostsController < ApplicationController
end
rescue_from Diaspora::NotMine do
- render text: I18n.t("posts.show.forbidden"), status: 403
+ render plain: I18n.t("posts.show.forbidden"), status: 403
end
def show
@@ -36,7 +36,7 @@ class PostsController < ApplicationController
oembed = params.slice(:format, :maxheight, :minheight)
render json: OEmbedPresenter.new(post, oembed)
rescue
- render nothing: true, status: 404
+ head :not_found
end
def interactions
@@ -45,7 +45,7 @@ class PostsController < ApplicationController
post = post_service.find!(params[:id])
render json: PostInteractionPresenter.new(post, current_user)
}
- format.any { render nothing: true, status: 406 }
+ format.any { head :not_acceptable }
end
end
@@ -55,19 +55,19 @@ class PostsController < ApplicationController
if params[:id].present? && params[:q].present?
render json: post_service.mentionable_in_comment(params[:id], params[:q])
else
- render nothing: true, status: 204
+ head :no_content
end
}
- format.any { render nothing: true, status: 406 }
+ format.any { head :not_acceptable }
end
rescue ActiveRecord::RecordNotFound
- render nothing: true, status: 404
+ head :not_found
end
def destroy
post_service.destroy(params[:id])
respond_to do |format|
- format.json { render nothing: true, status: 204 }
+ format.json { head :no_content }
format.any { redirect_to stream_path }
end
end
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index bb4d9b070..9daa4640d 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -48,7 +48,7 @@ class ProfilesController < ApplicationController
end
respond_to do |format|
- format.js { render :nothing => true, :status => 200 }
+ format.js { head :ok }
format.any {
if current_user.getting_started?
redirect_to getting_started_path
@@ -77,6 +77,6 @@ class ProfilesController < ApplicationController
def profile_params
params.require(:profile).permit(:first_name, :last_name, :gender, :bio,
:location, :searchable, :tag_string, :nsfw,
- :public_details, date: %i(year month day)) || {}
+ :public_details, date: %i[year month day]).to_h || {}
end
end
diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb
index 8e0826c1f..f51d2d043 100644
--- a/app/controllers/report_controller.rb
+++ b/app/controllers/report_controller.rb
@@ -31,7 +31,7 @@ class ReportController < ApplicationController
if report.save
render json: true, status: 200
else
- render nothing: true, status: 409
+ head :conflict
end
end
diff --git a/app/controllers/reshares_controller.rb b/app/controllers/reshares_controller.rb
index 4add93174..846091398 100644
--- a/app/controllers/reshares_controller.rb
+++ b/app/controllers/reshares_controller.rb
@@ -5,7 +5,7 @@ class ResharesController < ApplicationController
def create
reshare = reshare_service.create(params[:root_guid])
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
- render text: I18n.t("reshares.create.error"), status: 422
+ render plain: I18n.t("reshares.create.error"), status: 422
else
render json: ExtremePostPresenter.new(reshare, current_user), status: 201
end
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index f3a320615..e1f754a43 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -1,24 +1,24 @@
class SearchController < ApplicationController
before_action :authenticate_user!
-
+
def search
if search_query.starts_with?('#')
if search_query.length > 1
- respond_to do |format|
+ respond_to do |format|
format.json {redirect_to tags_path(:q => search_query.delete("#."))}
format.any {redirect_to tag_path(:name => search_query.delete("#."))}
end
else
flash[:error] = I18n.t('tags.show.none', :name => search_query)
- redirect_to :back
+ redirect_back fallback_location: stream_path
end
else
redirect_to people_path(:q => search_query)
- end
+ end
end
-
+
private
-
+
def search_query
@search_query ||= (params[:q] || params[:term] || '').strip
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 61f464209..74fd1f818 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -3,8 +3,8 @@
# the COPYRIGHT file.
class SessionsController < Devise::SessionsController
- after_filter :reset_authentication_token, :only => [:create]
- before_filter :reset_authentication_token, :only => [:destroy]
+ after_action :reset_authentication_token, only: [:create]
+ before_action :reset_authentication_token, only: [:destroy]
def reset_authentication_token
current_user.reset_authentication_token! unless current_user.nil?
diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb
index e65e4b54a..58ae46536 100644
--- a/app/controllers/status_messages_controller.rb
+++ b/app/controllers/status_messages_controller.rb
@@ -47,14 +47,8 @@ class StatusMessagesController < ApplicationController
end
def create
- normalized_params = params.merge(
- services: normalize_services,
- aspect_ids: normalize_aspect_ids,
- public: normalize_public_flag
- )
- status_message = StatusMessageCreationService.new(current_user).create(normalized_params)
+ status_message = StatusMessageCreationService.new(current_user).create(normalize_params)
respond_to do |format|
- format.html { redirect_to :back }
format.mobile { redirect_to stream_path }
format.json { render json: PostPresenter.new(status_message, current_user), status: 201 }
end
@@ -71,9 +65,8 @@ class StatusMessagesController < ApplicationController
def handle_create_error(error)
logger.debug error
respond_to do |format|
- format.html { redirect_to :back }
format.mobile { redirect_to stream_path }
- format.json { render text: error.message, status: 403 }
+ format.json { render plain: error.message, status: 403 }
end
end
@@ -89,8 +82,19 @@ class StatusMessagesController < ApplicationController
request.env["HTTP_REFERER"].include?("/people/" + current_user.guid)
end
- def normalize_services
- [*params[:services]].compact
+ def normalize_params
+ params.permit(
+ :location_address,
+ :location_coords,
+ :poll_question,
+ status_message: %i[text provider_display_name],
+ poll_answers: []
+ ).to_h.merge(
+ services: [*params[:services]].compact,
+ aspect_ids: normalize_aspect_ids,
+ public: [*params[:aspect_ids]].first == "public",
+ photos: [*params[:photos]].compact
+ )
end
def normalize_aspect_ids
@@ -102,10 +106,6 @@ class StatusMessagesController < ApplicationController
end
end
- def normalize_public_flag
- [*params[:aspect_ids]].first == "public"
- end
-
def remove_getting_started
current_user.disable_getting_started
end
diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb
index 72ca6fd24..a82d16dd9 100644
--- a/app/controllers/tag_followings_controller.rb
+++ b/app/controllers/tag_followings_controller.rb
@@ -15,7 +15,7 @@ class TagFollowingsController < ApplicationController
name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])
if name_normalized.nil? || name_normalized.empty?
- render :nothing => true, :status => 403
+ head :forbidden
else
@tag = ActsAsTaggableOn::Tag.find_or_create_by(name: name_normalized)
@tag_following = current_user.tag_followings.new(:tag_id => @tag.id)
@@ -23,7 +23,7 @@ class TagFollowingsController < ApplicationController
if @tag_following.save
render :json => @tag.to_json, :status => 201
else
- render :nothing => true, :status => 403
+ head :forbidden
end
end
end
@@ -35,11 +35,11 @@ class TagFollowingsController < ApplicationController
if tag_following && tag_following.destroy
respond_to do |format|
- format.any(:js, :json) { render :nothing => true, :status => 204 }
+ format.any(:js, :json) { head :no_content }
end
else
respond_to do |format|
- format.any(:js, :json) {render :nothing => true, :status => 403}
+ format.any(:js, :json) { head :forbidden }
end
end
end
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 30ddfec00..d201fd905 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -24,8 +24,8 @@ class TagsController < ApplicationController
end
else
respond_to do |format|
- format.json{ render :nothing => true, :status => 422 }
- format.html{ redirect_to tag_path('partytimeexcellent') }
+ format.json { head :unprocessable_entity }
+ format.html { redirect_to tag_path("partytimeexcellent") }
end
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 6b7502828..e6dbb3449 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -46,7 +46,7 @@ class UsersController < ApplicationController
flash[:error] = t("users.update.settings_not_updated")
end
- redirect_to :back
+ redirect_back fallback_location: privacy_settings_path
end
def destroy
@@ -60,7 +60,7 @@ class UsersController < ApplicationController
else
flash[:error] = t "users.destroy.no_password"
end
- redirect_to :back
+ redirect_back fallback_location: edit_user_path
end
end
diff --git a/app/helpers/meta_data_helper.rb b/app/helpers/meta_data_helper.rb
index 6b3dcfc7f..7fbe86ab8 100644
--- a/app/helpers/meta_data_helper.rb
+++ b/app/helpers/meta_data_helper.rb
@@ -11,7 +11,7 @@ module MetaDataHelper
end
def default_image_url
- asset_url "assets/branding/logos/asterisk.png"
+ asset_url("assets/branding/logos/asterisk.png", skip_pipeline: true)
end
def default_author_name
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 000000000..e5ed1ffd0
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,3 @@
+class ApplicationMailer < ActionMailer::Base
+ default from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>"
+end
diff --git a/app/mailers/diaspora_devise_mailer.rb b/app/mailers/diaspora_devise_mailer.rb
index 9a18ffb38..069b488b5 100644
--- a/app/mailers/diaspora_devise_mailer.rb
+++ b/app/mailers/diaspora_devise_mailer.rb
@@ -1,5 +1,5 @@
class DiasporaDeviseMailer < Devise::Mailer
- default :from => AppConfig.mail.sender_address
+ default from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>"
def self.mailer_name
"devise/mailer"
diff --git a/app/mailers/export_mailer.rb b/app/mailers/export_mailer.rb
index a0bc8b5e5..5139be734 100644
--- a/app/mailers/export_mailer.rb
+++ b/app/mailers/export_mailer.rb
@@ -1,6 +1,4 @@
-class ExportMailer < ActionMailer::Base
- default from: AppConfig.mail.sender_address
-
+class ExportMailer < ApplicationMailer
def export_complete_for(user)
@user = user
diff --git a/app/mailers/maintenance.rb b/app/mailers/maintenance.rb
index 6b0f2e07b..185b4f949 100644
--- a/app/mailers/maintenance.rb
+++ b/app/mailers/maintenance.rb
@@ -1,6 +1,4 @@
-class Maintenance < ActionMailer::Base
- default :from => AppConfig.mail.sender_address
-
+class Maintenance < ApplicationMailer
def account_removal_warning(user)
@user = user
@login_url = new_user_session_url
diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb
index d58a58761..187c7b0ed 100644
--- a/app/mailers/notifier.rb
+++ b/app/mailers/notifier.rb
@@ -1,4 +1,4 @@
-class Notifier < ActionMailer::Base
+class Notifier < ApplicationMailer
helper :application
helper :notifier
helper :people
diff --git a/app/mailers/report_mailer.rb b/app/mailers/report_mailer.rb
index 498413367..0ac76892f 100644
--- a/app/mailers/report_mailer.rb
+++ b/app/mailers/report_mailer.rb
@@ -1,6 +1,4 @@
-class ReportMailer < ActionMailer::Base
- default from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>"
-
+class ReportMailer < ApplicationMailer
def self.new_report(report_id)
report = Report.find_by_id(report_id)
Role.moderators.map {|role| super(report.item_type, report.item_id, report.text, role) }
diff --git a/app/models/account_deletion.rb b/app/models/account_deletion.rb
index bab962dca..cc9445310 100644
--- a/app/models/account_deletion.rb
+++ b/app/models/account_deletion.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class AccountDeletion < ActiveRecord::Base
+class AccountDeletion < ApplicationRecord
include Diaspora::Federated::Base
scope :uncompleted, -> { where('completed_at is null') }
diff --git a/app/models/api/openid_connect/authorization.rb b/app/models/api/openid_connect/authorization.rb
index 41c6c0e6f..a57231552 100644
--- a/app/models/api/openid_connect/authorization.rb
+++ b/app/models/api/openid_connect/authorization.rb
@@ -2,12 +2,11 @@
module Api
module OpenidConnect
- class Authorization < ActiveRecord::Base
+ class Authorization < ApplicationRecord
belongs_to :user
belongs_to :o_auth_application
- validates :user, presence: true, uniqueness: {scope: :o_auth_application}
- validates :o_auth_application, presence: true
+ validates :user, uniqueness: {scope: :o_auth_application}
validate :validate_scope_names
serialize :scopes, JSON
diff --git a/app/models/api/openid_connect/o_auth_access_token.rb b/app/models/api/openid_connect/o_auth_access_token.rb
index 053bc86df..e2089fff8 100644
--- a/app/models/api/openid_connect/o_auth_access_token.rb
+++ b/app/models/api/openid_connect/o_auth_access_token.rb
@@ -23,13 +23,12 @@
module Api
module OpenidConnect
- class OAuthAccessToken < ActiveRecord::Base
+ class OAuthAccessToken < ApplicationRecord
belongs_to :authorization
before_validation :setup, on: :create
validates :token, presence: true, uniqueness: true
- validates :authorization, presence: true
scope :valid, ->(time) { where("expires_at >= ?", time) }
diff --git a/app/models/api/openid_connect/o_auth_application.rb b/app/models/api/openid_connect/o_auth_application.rb
index ccceadfea..acf2817e4 100644
--- a/app/models/api/openid_connect/o_auth_application.rb
+++ b/app/models/api/openid_connect/o_auth_application.rb
@@ -25,7 +25,7 @@ require "digest"
module Api
module OpenidConnect
- class OAuthApplication < ActiveRecord::Base
+ class OAuthApplication < ApplicationRecord
has_many :authorizations, dependent: :destroy
has_many :user, through: :authorizations
diff --git a/app/models/api/openid_connect/pairwise_pseudonymous_identifier.rb b/app/models/api/openid_connect/pairwise_pseudonymous_identifier.rb
index 7aeccc9fa..520bc782c 100644
--- a/app/models/api/openid_connect/pairwise_pseudonymous_identifier.rb
+++ b/app/models/api/openid_connect/pairwise_pseudonymous_identifier.rb
@@ -23,13 +23,12 @@
module Api
module OpenidConnect
- class PairwisePseudonymousIdentifier < ActiveRecord::Base
+ class PairwisePseudonymousIdentifier < ApplicationRecord
self.table_name = "ppid"
- belongs_to :o_auth_application
+ belongs_to :o_auth_application, optional: true
belongs_to :user
- validates :user, presence: true
validates :identifier, presence: true, uniqueness: {scope: :user}
validates :guid, presence: true, uniqueness: true
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644
index 000000000..10a4cba84
--- /dev/null
+++ b/app/models/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+ self.abstract_class = true
+end
diff --git a/app/models/aspect.rb b/app/models/aspect.rb
index dfacdc811..4f6054dce 100644
--- a/app/models/aspect.rb
+++ b/app/models/aspect.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Aspect < ActiveRecord::Base
+class Aspect < ApplicationRecord
belongs_to :user
has_many :aspect_memberships, :dependent => :destroy
diff --git a/app/models/aspect_membership.rb b/app/models/aspect_membership.rb
index 8155c241f..8901f16a2 100644
--- a/app/models/aspect_membership.rb
+++ b/app/models/aspect_membership.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class AspectMembership < ActiveRecord::Base
+class AspectMembership < ApplicationRecord
belongs_to :aspect
belongs_to :contact
diff --git a/app/models/aspect_visibility.rb b/app/models/aspect_visibility.rb
index 88e645727..be36323cb 100644
--- a/app/models/aspect_visibility.rb
+++ b/app/models/aspect_visibility.rb
@@ -2,13 +2,11 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class AspectVisibility < ActiveRecord::Base
+class AspectVisibility < ApplicationRecord
belongs_to :aspect
- validates :aspect, :presence => true
belongs_to :shareable, :polymorphic => true
- validates :shareable, :presence => true
validates :aspect, uniqueness: {scope: %i(shareable_id shareable_type)}
end
diff --git a/app/models/block.rb b/app/models/block.rb
index 1eba8f4c8..57b470e58 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -1,11 +1,10 @@
-class Block < ActiveRecord::Base
+class Block < ApplicationRecord
belongs_to :person
belongs_to :user
delegate :name, to: :person, prefix: true
- validates :user_id, :presence => true
- validates :person_id, :presence => true, :uniqueness => { :scope => :user_id }
+ validates :person_id, uniqueness: {scope: :user_id}
validate :not_blocking_yourself
diff --git a/app/models/comment.rb b/app/models/comment.rb
index fb5446173..4b6baa250 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Comment < ActiveRecord::Base
+class Comment < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Fields::Guid
@@ -26,7 +26,6 @@ class Comment < ActiveRecord::Base
delegate :author_name, to: :parent, prefix: true
validates :text, :presence => true, :length => {:maximum => 65535}
- validates :parent, :presence => true #should be in relayable (pending on fixing Message)
has_many :reports, as: :item
diff --git a/app/models/comment_signature.rb b/app/models/comment_signature.rb
index 357bcb3b8..9e7aa9270 100644
--- a/app/models/comment_signature.rb
+++ b/app/models/comment_signature.rb
@@ -1,7 +1,6 @@
-class CommentSignature < ActiveRecord::Base
+class CommentSignature < ApplicationRecord
include Diaspora::Signature
self.primary_key = :comment_id
belongs_to :comment
- validates :comment, presence: true
end
diff --git a/app/models/contact.rb b/app/models/contact.rb
index c7970a2f9..666815d47 100644
--- a/app/models/contact.rb
+++ b/app/models/contact.rb
@@ -2,14 +2,11 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Contact < ActiveRecord::Base
+class Contact < ApplicationRecord
include Diaspora::Federated::Base
belongs_to :user
- validates :user, presence: true
-
belongs_to :person
- validates :person, presence: true
validates :person_id, uniqueness: {scope: :user_id}
diff --git a/app/models/conversation.rb b/app/models/conversation.rb
index 4802d247e..f597af001 100644
--- a/app/models/conversation.rb
+++ b/app/models/conversation.rb
@@ -1,4 +1,4 @@
-class Conversation < ActiveRecord::Base
+class Conversation < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Fields::Guid
include Diaspora::Fields::Author
diff --git a/app/models/conversation_visibility.rb b/app/models/conversation_visibility.rb
index 9c0afb2bd..39e7e66cd 100644
--- a/app/models/conversation_visibility.rb
+++ b/app/models/conversation_visibility.rb
@@ -1,4 +1,4 @@
-class ConversationVisibility < ActiveRecord::Base
+class ConversationVisibility < ApplicationRecord
belongs_to :conversation
belongs_to :person
@@ -6,7 +6,7 @@ class ConversationVisibility < ActiveRecord::Base
after_destroy :check_orphan_conversation
private
-
+
def check_orphan_conversation
conversation = Conversation.find_by_id(self.conversation.id)
if conversation
diff --git a/app/models/invitation_code.rb b/app/models/invitation_code.rb
index 7b732359d..1dd565871 100644
--- a/app/models/invitation_code.rb
+++ b/app/models/invitation_code.rb
@@ -1,8 +1,6 @@
-class InvitationCode < ActiveRecord::Base
+class InvitationCode < ApplicationRecord
belongs_to :user
- validates_presence_of :user
-
before_create :generate_token, :set_default_invite_count
delegate :name, to: :user, prefix: true
diff --git a/app/models/like.rb b/app/models/like.rb
index 78eb9c3da..828d5b8aa 100644
--- a/app/models/like.rb
+++ b/app/models/like.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Like < ActiveRecord::Base
+class Like < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Fields::Guid
include Diaspora::Fields::Author
diff --git a/app/models/like_signature.rb b/app/models/like_signature.rb
index 6978704a9..bc21533d4 100644
--- a/app/models/like_signature.rb
+++ b/app/models/like_signature.rb
@@ -1,7 +1,6 @@
-class LikeSignature < ActiveRecord::Base
+class LikeSignature < ApplicationRecord
include Diaspora::Signature
self.primary_key = :like_id
belongs_to :like
- validates :like, presence: true
end
diff --git a/app/models/location.rb b/app/models/location.rb
index 0620104ad..37132f147 100644
--- a/app/models/location.rb
+++ b/app/models/location.rb
@@ -1,4 +1,4 @@
-class Location < ActiveRecord::Base
+class Location < ApplicationRecord
before_validation :split_coords, on: :create
validates_presence_of :lat, :lng
diff --git a/app/models/mention.rb b/app/models/mention.rb
index 597cebe94..c5bb859e5 100644
--- a/app/models/mention.rb
+++ b/app/models/mention.rb
@@ -2,11 +2,9 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Mention < ActiveRecord::Base
+class Mention < ApplicationRecord
belongs_to :mentions_container, polymorphic: true
belongs_to :person
- validates :mentions_container, presence: true
- validates :person, presence: true
scope :local, -> {
joins(:person).where.not(people: {owner_id: nil})
diff --git a/app/models/message.rb b/app/models/message.rb
index 2a56ea47a..95992e689 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -1,4 +1,4 @@
-class Message < ActiveRecord::Base
+class Message < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Fields::Guid
include Diaspora::Fields::Author
@@ -7,7 +7,6 @@ class Message < ActiveRecord::Base
delegate :name, to: :author, prefix: true
- validates :conversation, presence: true
validates :text, presence: true
validate :participant_of_parent_conversation
diff --git a/app/models/notification.rb b/app/models/notification.rb
index c4b557045..f1adf5325 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
#
-class Notification < ActiveRecord::Base
+class Notification < ApplicationRecord
belongs_to :recipient, class_name: "User"
has_many :notification_actors, dependent: :destroy
has_many :actors, class_name: "Person", through: :notification_actors, source: :person
diff --git a/app/models/notification_actor.rb b/app/models/notification_actor.rb
index 2b47a5cff..beaeefbb6 100644
--- a/app/models/notification_actor.rb
+++ b/app/models/notification_actor.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class NotificationActor < ActiveRecord::Base
+class NotificationActor < ApplicationRecord
belongs_to :notification
belongs_to :person
diff --git a/app/models/o_embed_cache.rb b/app/models/o_embed_cache.rb
index 17e6f073f..30967d1bd 100644
--- a/app/models/o_embed_cache.rb
+++ b/app/models/o_embed_cache.rb
@@ -1,4 +1,4 @@
-class OEmbedCache < ActiveRecord::Base
+class OEmbedCache < ApplicationRecord
serialize :data
validates :data, :presence => true
diff --git a/app/models/open_graph_cache.rb b/app/models/open_graph_cache.rb
index ffae81c94..0aa0a2fe6 100644
--- a/app/models/open_graph_cache.rb
+++ b/app/models/open_graph_cache.rb
@@ -1,4 +1,4 @@
-class OpenGraphCache < ActiveRecord::Base
+class OpenGraphCache < ApplicationRecord
validates :title, :presence => true
validates :ob_type, :presence => true
validates :image, :presence => true
diff --git a/app/models/participation.rb b/app/models/participation.rb
index 94d82fb95..4bdda1a92 100644
--- a/app/models/participation.rb
+++ b/app/models/participation.rb
@@ -1,4 +1,4 @@
-class Participation < ActiveRecord::Base
+class Participation < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Fields::Guid
include Diaspora::Fields::Author
diff --git a/app/models/person.rb b/app/models/person.rb
index 169a84c18..f8add5a52 100644
--- a/app/models/person.rb
+++ b/app/models/person.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Person < ActiveRecord::Base
+class Person < ApplicationRecord
include Diaspora::Fields::Guid
# NOTE API V1 to be extracted
@@ -44,8 +44,8 @@ class Person < ActiveRecord::Base
has_many :roles
- belongs_to :owner, :class_name => 'User'
- belongs_to :pod
+ belongs_to :owner, class_name: "User", optional: true
+ belongs_to :pod, optional: true
has_many :notification_actors
has_many :notifications, :through => :notification_actors
@@ -100,10 +100,12 @@ class Person < ActiveRecord::Base
# @return [Person::ActiveRecord_Relation]
scope :find_by_substring, ->(search_str) {
search_str.strip!
- return none if search_str.blank? || search_str.size < 2
-
- sql, tokens = search_query_string(search_str)
- joins(:profile).where(sql, *tokens)
+ if search_str.blank? || search_str.size < 2
+ none
+ else
+ sql, tokens = search_query_string(search_str)
+ joins(:profile).where(sql, *tokens)
+ end
}
# Left joins likes and comments to a specific post where people are authors of these comments and likes
diff --git a/app/models/photo.rb b/app/models/photo.rb
index 17e9b9ff8..7fa0c3871 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Photo < ActiveRecord::Base
+class Photo < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Commentable
include Diaspora::Shareable
@@ -37,7 +37,7 @@ class Photo < ActiveRecord::Base
mount_uploader :processed_image, ProcessedImage
mount_uploader :unprocessed_image, UnprocessedImage
- belongs_to :status_message, :foreign_key => :status_message_guid, :primary_key => :guid
+ belongs_to :status_message, foreign_key: :status_message_guid, primary_key: :guid, optional: true
validates_associated :status_message
delegate :author_name, to: :status_message, prefix: true
diff --git a/app/models/pod.rb b/app/models/pod.rb
index dde1e28f1..b88c76cde 100644
--- a/app/models/pod.rb
+++ b/app/models/pod.rb
@@ -1,4 +1,4 @@
-class Pod < ActiveRecord::Base
+class Pod < ApplicationRecord
enum status: %i(
unchecked
no_errors
diff --git a/app/models/poll.rb b/app/models/poll.rb
index fa9033577..15589d601 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -1,4 +1,4 @@
-class Poll < ActiveRecord::Base
+class Poll < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Fields::Guid
diff --git a/app/models/poll_answer.rb b/app/models/poll_answer.rb
index 3387efe09..d91c4e13a 100644
--- a/app/models/poll_answer.rb
+++ b/app/models/poll_answer.rb
@@ -1,4 +1,4 @@
-class PollAnswer < ActiveRecord::Base
+class PollAnswer < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Fields::Guid
diff --git a/app/models/poll_participation.rb b/app/models/poll_participation.rb
index 7e653bb65..24f99f9ef 100644
--- a/app/models/poll_participation.rb
+++ b/app/models/poll_participation.rb
@@ -1,4 +1,4 @@
-class PollParticipation < ActiveRecord::Base
+class PollParticipation < ApplicationRecord
include Diaspora::Federated::Base
include Diaspora::Fields::Guid
include Diaspora::Fields::Author
@@ -12,7 +12,6 @@ class PollParticipation < ActiveRecord::Base
alias_attribute :parent, :poll
- validates :poll_answer, presence: true
validate :not_already_participated
def poll_answer_guid=(new_poll_answer_guid)
diff --git a/app/models/poll_participation_signature.rb b/app/models/poll_participation_signature.rb
index 90701f286..a32b8653e 100644
--- a/app/models/poll_participation_signature.rb
+++ b/app/models/poll_participation_signature.rb
@@ -1,7 +1,6 @@
-class PollParticipationSignature < ActiveRecord::Base
+class PollParticipationSignature < ApplicationRecord
include Diaspora::Signature
self.primary_key = :poll_participation_id
belongs_to :poll_participation
- validates :poll_participation, presence: true
end
diff --git a/app/models/post.rb b/app/models/post.rb
index 58dbf12cf..4a6c51744 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Post < ActiveRecord::Base
+class Post < ApplicationRecord
self.include_root_in_json = false
include ApplicationHelper
@@ -24,8 +24,8 @@ class Post < ActiveRecord::Base
has_many :reshares, class_name: "Reshare", foreign_key: :root_guid, primary_key: :guid
has_many :resharers, class_name: "Person", through: :reshares, source: :author
- belongs_to :o_embed_cache
- belongs_to :open_graph_cache
+ belongs_to :o_embed_cache, optional: true
+ belongs_to :open_graph_cache, optional: true
validates_uniqueness_of :id
diff --git a/app/models/profile.rb b/app/models/profile.rb
index 82413ccd2..dc5398133 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Profile < ActiveRecord::Base
+class Profile < ApplicationRecord
self.include_root_in_json = false
include Diaspora::Federated::Base
@@ -106,10 +106,6 @@ class Profile < ActiveRecord::Base
end
end
- def formatted_birthday
- birthday.to_s(:long).gsub(/, 100[0|4]/, "") if birthday.present?
- end
-
def bio_message
@bio_message ||= Diaspora::MessageRenderer.new(bio)
end
diff --git a/app/models/report.rb b/app/models/report.rb
index a116e9083..2f28cfc4c 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -1,4 +1,4 @@
-class Report < ActiveRecord::Base
+class Report < ApplicationRecord
validates :user_id, presence: true
validates :item_id, presence: true
validates :item_type, presence: true, inclusion: {
@@ -9,8 +9,8 @@ class Report < ActiveRecord::Base
validate :post_or_comment_does_exist, :on => :create
belongs_to :user
- belongs_to :post
- belongs_to :comment
+ belongs_to :post, optional: true
+ belongs_to :comment, optional: true
belongs_to :item, polymorphic: true
after_commit :send_report_notification, :on => :create
diff --git a/app/models/reshare.rb b/app/models/reshare.rb
index a88208248..bc6d8bfa1 100644
--- a/app/models/reshare.rb
+++ b/app/models/reshare.rb
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
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, optional: true
validate :root_must_be_public
validates_presence_of :root, :on => :create
validates_uniqueness_of :root_guid, :scope => :author_id
diff --git a/app/models/role.rb b/app/models/role.rb
index cbe5644ef..98601bb7b 100644
--- a/app/models/role.rb
+++ b/app/models/role.rb
@@ -1,9 +1,8 @@
# NOTE add the person object you want to attach role to...
-class Role < ActiveRecord::Base
+class Role < ApplicationRecord
belongs_to :person
- validates :person, presence: true
validates :name, uniqueness: {scope: :person_id}
validates :name, inclusion: {in: %w(admin moderator spotlight)}
diff --git a/app/models/service.rb b/app/models/service.rb
index 57322ce8c..890fc02bc 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class Service < ActiveRecord::Base
+class Service < ApplicationRecord
attr_accessor :provider, :info, :access_level
belongs_to :user
diff --git a/app/models/share_visibility.rb b/app/models/share_visibility.rb
index bffdf91cc..18c920a53 100644
--- a/app/models/share_visibility.rb
+++ b/app/models/share_visibility.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class ShareVisibility < ActiveRecord::Base
+class ShareVisibility < ApplicationRecord
belongs_to :user
belongs_to :shareable, polymorphic: :true
@@ -22,7 +22,7 @@ class ShareVisibility < ActiveRecord::Base
# @param share [Shareable]
# @return [void]
def self.batch_import(user_ids, share)
- return false unless ShareVisibility.new(shareable_id: share.id, shareable_type: share.class.base_class.to_s).valid?
+ return false if share.public?
user_ids -= ShareVisibility.for_shareable(share).where(user_id: user_ids).pluck(:user_id)
return false if user_ids.empty?
diff --git a/app/models/signature_order.rb b/app/models/signature_order.rb
index 83cbfb51a..e65d0fae3 100644
--- a/app/models/signature_order.rb
+++ b/app/models/signature_order.rb
@@ -1,3 +1,3 @@
-class SignatureOrder < ActiveRecord::Base
+class SignatureOrder < ApplicationRecord
validates :order, presence: true, uniqueness: true
end
diff --git a/app/models/tag_following.rb b/app/models/tag_following.rb
index 915221856..bd1cb62d2 100644
--- a/app/models/tag_following.rb
+++ b/app/models/tag_following.rb
@@ -1,4 +1,4 @@
-class TagFollowing < ActiveRecord::Base
+class TagFollowing < ApplicationRecord
belongs_to :user
belongs_to :tag, :class_name => "ActsAsTaggableOn::Tag"
diff --git a/app/models/user.rb b/app/models/user.rb
index 2061efc9b..629649d4e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-class User < ActiveRecord::Base
+class User < ApplicationRecord
include AuthenticationToken
include Connecting
include Querying
@@ -51,8 +51,8 @@ class User < ActiveRecord::Base
has_many :aspects, -> { order('order_id ASC') }
- belongs_to :auto_follow_back_aspect, :class_name => 'Aspect'
- belongs_to :invited_by, :class_name => 'User'
+ belongs_to :auto_follow_back_aspect, class_name: "Aspect", optional: true
+ belongs_to :invited_by, class_name: "User", optional: true
has_many :aspect_memberships, :through => :aspects
@@ -473,14 +473,17 @@ class User < ActiveRecord::Base
def guard_unconfirmed_email
self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email
- if unconfirmed_email_changed?
- self.confirm_email_token = unconfirmed_email ? SecureRandom.hex(15) : nil
- end
+ return unless will_save_change_to_unconfirmed_email?
+
+ self.confirm_email_token = unconfirmed_email ? SecureRandom.hex(15) : nil
end
# Whenever email is set, clear all unconfirmed emails which match
def remove_invalid_unconfirmed_emails
- User.where(unconfirmed_email: email).update_all(unconfirmed_email: nil, confirm_email_token: nil) if email_changed?
+ return unless saved_change_to_email?
+ # rubocop:disable Rails/SkipsModelValidations
+ User.where(unconfirmed_email: email).update_all(unconfirmed_email: nil, confirm_email_token: nil)
+ # rubocop:enable Rails/SkipsModelValidations
end
# Generate public/private keys for User and associated Person
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index ea4f92425..11ba7038d 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -1,4 +1,4 @@
-class UserPreference < ActiveRecord::Base
+class UserPreference < ApplicationRecord
belongs_to :user
validate :must_be_valid_email_type
diff --git a/app/services/status_message_creation_service.rb b/app/services/status_message_creation_service.rb
index 94a16d795..a262d2e54 100644
--- a/app/services/status_message_creation_service.rb
+++ b/app/services/status_message_creation_service.rb
@@ -36,7 +36,8 @@ class StatusMessageCreationService
if params[:poll_question].present?
status_message.build_poll(question: params[:poll_question])
[*params[:poll_answers]].each do |poll_answer|
- status_message.poll.poll_answers.build(answer: poll_answer)
+ answer = status_message.poll.poll_answers.build(answer: poll_answer)
+ answer.poll = status_message.poll
end
end
end
diff --git a/app/workers/deferred_dispatch.rb b/app/workers/deferred_dispatch.rb
index 49d0aa365..3c60ade93 100644
--- a/app/workers/deferred_dispatch.rb
+++ b/app/workers/deferred_dispatch.rb
@@ -9,7 +9,7 @@ module Workers
def perform(user_id, object_class_name, object_id, opts)
user = User.find(user_id)
object = object_class_name.constantize.find(object_id)
- opts = HashWithIndifferentAccess.new(opts)
+ opts = ActiveSupport::HashWithIndifferentAccess.new(opts)
Diaspora::Federation::Dispatcher.build(user, object, opts).dispatch
rescue ActiveRecord::RecordNotFound # The target got deleted before the job was run
diff --git a/app/workers/deferred_retraction.rb b/app/workers/deferred_retraction.rb
index f55e9c405..85ee2c1ab 100644
--- a/app/workers/deferred_retraction.rb
+++ b/app/workers/deferred_retraction.rb
@@ -10,7 +10,7 @@ module Workers
user = User.find(user_id)
subscribers = Person.where(id: recipient_ids)
object = retraction_class.constantize.new(retraction_data.deep_symbolize_keys, subscribers)
- opts = HashWithIndifferentAccess.new(opts)
+ opts = ActiveSupport::HashWithIndifferentAccess.new(opts)
Diaspora::Federation::Dispatcher.build(user, object, opts).dispatch
end
diff --git a/app/workers/delete_post_from_service.rb b/app/workers/delete_post_from_service.rb
index 7d0bfe1fd..33b841f6a 100644
--- a/app/workers/delete_post_from_service.rb
+++ b/app/workers/delete_post_from_service.rb
@@ -8,7 +8,7 @@ module Workers
def perform(service_id, opts)
service = Service.find_by_id(service_id)
- opts = HashWithIndifferentAccess.new(opts)
+ opts = ActiveSupport::HashWithIndifferentAccess.new(opts)
service.delete_from_service(opts)
end
end
diff --git a/bin/rails b/bin/rails
index 0af1c3baf..5badb2fde 100755
--- a/bin/rails
+++ b/bin/rails
@@ -4,8 +4,6 @@ begin
rescue LoadError => e
raise unless e.message.include?('spring')
end
-# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
-
-APP_PATH = File.expand_path('../../config/application', __FILE__)
-require File.expand_path('../../config/boot', __FILE__)
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
require 'rails/commands'
diff --git a/config/application.rb b/config/application.rb
index 619b66070..6410e0bc1 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,7 +1,10 @@
require_relative 'boot'
require 'rails/all'
-Bundler.require(:default, *Bundler.settings.with, Rails.env)
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups(*Bundler.settings.with))
# Do not dump the limit of boolean fields on MySQL,
# since that generates a db/schema.rb that's incompatible
@@ -24,6 +27,9 @@ require_relative 'asset_sync'
module Diaspora
class Application < Rails::Application
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 5.1
+
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
@@ -64,8 +70,9 @@ module Diaspora
# Speed up precompile by not loading the environment
config.assets.initialize_on_precompile = false
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
- config.assets.precompile += %w(
+ # Precompile additional assets.
+ # (application.js, application.css, and all non-JS/CSS in the app/assets are already added)
+ config.assets.precompile += %w[
contact-list.js
ie.js
jquery3.js
@@ -82,10 +89,7 @@ module Diaspora
rtl.css
color_themes/*/desktop.css
color_themes/*/mobile.css
- )
-
- # Version of your assets, change this if you want to expire all your assets
- config.assets.version = '1.0'
+ ]
# See lib/tasks/assets.rake: non_digest_assets
config.assets.non_digest_assets = %w(branding/logos/asterisk.png)
@@ -96,9 +100,6 @@ module Diaspora
g.test_framework :rspec
end
- # Will be default with Rails 5
- config.active_record.raise_in_transactional_callbacks = true
-
# Setup action mailer early
config.action_mailer.default_url_options = {
protocol: AppConfig.pod_uri.scheme,
diff --git a/config/boot.rb b/config/boot.rb
index 6e3d23427..e9f0721fe 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,9 +1,6 @@
-# Set up gems listed in the Gemfile.
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
-require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
-# Ensure Builder is loaded
-require 'active_support/builder' unless defined?(Builder)
+require "bundler/setup" # Set up gems listed in the Gemfile.
# Load configuration early
-require_relative 'load_config'
+require_relative "load_config"
diff --git a/config/environment.rb b/config/environment.rb
index c9482d0ee..426333bb4 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,5 +1,5 @@
-# Load the rails application
+# Load the Rails application.
require_relative 'application'
-# Initialize the rails application
-Diaspora::Application.initialize!
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index c32bb8287..f422f016e 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,5 +1,5 @@
-Diaspora::Application.configure do
- # Settings specified here will take precedence over those in config/application.rb
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
@@ -9,30 +9,40 @@ Diaspora::Application.configure do
# Do not eager load code on boot.
config.eager_load = false
- # Show full error reports and disable caching
- config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
+ # Show full error reports.
+ config.consider_all_requests_local = true
- # Don't care if the mailer can't send
+ # Enable/disable caching. By default caching is disabled.
+ if Rails.root.join("tmp", "caching-dev.txt").exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ "Cache-Control" => "public, max-age=#{2.days.seconds.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
- # Raise an error on page load if there are pending migrations
- config.active_record.migration_error = :page_load
+ config.action_mailer.perform_caching = false
- # Print deprecation notices to the Rails logger
+ # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
- # Only use best-standards-support built into browsers
- config.action_dispatch.best_standards_support = :builtin
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
-
- # Do not compress assets
- config.assets.compress = false
-
- # Expands the lines which load the assets
+ # Debug mode disables concatenation and preprocessing of assets.
+ # This option may cause significant delays in view rendering with a large
+ # number of complex assets.
config.assets.debug = true
- # No assets request logging
+ # Suppress logger output for asset requests.
config.assets.quiet = true
# Set the logging destination(s)
@@ -41,6 +51,13 @@ Diaspora::Application.configure do
# Show the logging configuration on STDOUT
config.show_log_configuration = true
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+
# Speed up asset serving
config.middleware.insert 0, TurboDevAssets
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index a624236ab..b6cdb8cab 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,35 +1,51 @@
-Diaspora::Application.configure do
- # Settings specified here will take precedence over those in config/application.rb
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
- # Code is not reloaded between requests
+ # Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
- # your application in memory, allowing both thread web servers
+ # your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
- # Full error reports are disabled and caching is turned on
+ # Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
- # Disable Rails's static asset server (Apache or nginx will already do this)
- config.serve_static_files = false
+ # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
+ # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
+ # `config/secrets.yml.key`.
+ config.read_encrypted_secrets = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
- # Don't fallback to assets pipeline if a precompiled asset is missed
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
- # Generate digests for assets URLs
+ # Generate digests for assets URLs.
config.assets.digest = true
- # Specifies the header that your server uses for sending files
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ if AppConfig.environment.assets.host.present?
+ config.action_controller.asset_host = AppConfig.environment.assets.host.get
+ end
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Mount Action Cable outside main process or domain
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
@@ -37,44 +53,44 @@ Diaspora::Application.configure do
# Log level
config.log_level = :info
+ # Prepend all log lines with the following tags.
+ # config.log_tags = [ :request_id ]
+
# Set the logging destination(s)
config.log_to = %w[file]
# Show the logging configuration on STDOUT
config.show_log_configuration = false
- # Prepend all log lines with the following tags
- # config.log_tags = [ :subdomain, :uuid ]
-
- # Use a different logger for distributed setups
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
-
- # Use a different cache store in production
+ # Use a different cache store in production.
# config.cache_store = :mem_cache_store
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
- # config.action_controller.asset_host = "http://assets.example.com"
+ config.action_mailer.perform_caching = false
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
- # config.assets.precompile += %w( search.js )
-
- # Disable delivery errors, bad email addresses will be ignored
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
- # Enable autoload for rake tasks
- config.dependency_loading = true if $rails_rake_task
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
- # the I18n.default_locale when a translation can not be found)
+ # the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
- # Send deprecation notices to registered listeners
+ # Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
- # For nginx:
- config.action_dispatch.x_sendfile_header = "X-Accel-Redirect"
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ # config.log_formatter = ::Logger::Formatter.new
- if AppConfig.environment.assets.host.present?
- config.action_controller.asset_host = AppConfig.environment.assets.host.get
- end
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ # if ENV["RAILS_LOG_TO_STDOUT"].present?
+ # logger = ActiveSupport::Logger.new(STDOUT)
+ # logger.formatter = config.log_formatter
+ # config.logger = ActiveSupport::TaggedLogging.new(logger)
+ # end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 7df9c1b93..d9d87dbd0 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,5 +1,5 @@
-Diaspora::Application.configure do
- # Settings specified here will take precedence over those in config/application.rb
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
@@ -12,11 +12,13 @@ Diaspora::Application.configure do
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
- # Configure static asset server for tests with Cache-Control for performance
- config.serve_static_files = true
- config.static_cache_control = "public, max-age=3600"
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ "Cache-Control" => "public, max-age=#{1.hour.seconds.to_i}"
+ }
- # No assets request logging
+ # Suppress logger output for asset requests.
config.assets.quiet = true
# Precompile poltergeist_disable_transition.css for tests
@@ -30,24 +32,28 @@ Diaspora::Application.configure do
color_themes/original/mobile.css
]
- # Show full error reports and disable caching
+ # Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
- # Raise exceptions instead of rendering exception templates
- config.action_dispatch.show_exceptions = true
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
- # Disable request forgery protection in test environment
- config.action_controller.allow_forgery_protection = false
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+ config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
- # Print deprecation notices to the stderr
+ # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Set the logging destination(s)
config.log_to = %w[file]
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
end
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
new file mode 100644
index 000000000..51639b67a
--- /dev/null
+++ b/config/initializers/application_controller_renderer.rb
@@ -0,0 +1,6 @@
+# Be sure to restart your server when you modify this file.
+
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 686871f66..33e369e29 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -1,15 +1,26 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
+# Be sure to restart your server when you modify this file.
# bootstrap-markdown plugin relies on rails-assets-bootstrap gem but we use
# bootstrap-sass this line makes sure we exclude every asset comming
# from rails-assets-bootstrap to prevent conflicts with bootstrap-sass
-Rails.configuration.assets.paths.reject! do |path|
- path.include?("rails-assets-bootstrap") && !path.include?("rails-assets-bootstrap-markdown")
+
+# See https://github.com/tenex/rails-assets/issues/314
+Rails.application.config.after_initialize do
+ # add the gem names you wish to reject to the below array
+ excluded_gem_names = ["rails-assets-bootstrap"]
+
+ excluded_gem_full_names = Gem::Specification.select {|g| excluded_gem_names.include? g.name }.flat_map(&:full_name)
+ Rails.application.config.assets.paths.reject! do |path|
+ excluded_gem_full_names.any? {|gem_name| path.include? gem_name }
+ end
end
-Diaspora::Application.configure do
- config.serve_static_files = AppConfig.environment.assets.serve?
- # config.static_cache_control = "public, max-age=3600" if AppConfig[:serve_static_assets].to_s == 'true'
-end
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = "1.0"
+
+# Add additional assets to the asset load path.
+# Rails.application.config.assets.paths << Emoji.images_path
+# Add Yarn node_modules folder to the asset load path.
+# Rails.application.config.assets.paths << Rails.root.join("node_modules")
+
+Rails.application.config.public_file_server.enabled = AppConfig.environment.assets.serve?
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
new file mode 100644
index 000000000..59385cdf3
--- /dev/null
+++ b/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
new file mode 100644
index 000000000..1389e86a3
--- /dev/null
+++ b/config/initializers/cookies_serializer.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :marshal
diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb
index a50aead3e..0fccba3fe 100644
--- a/config/initializers/cors.rb
+++ b/config/initializers/cors.rb
@@ -1,4 +1,11 @@
-Rails.application.config.middleware.insert 0, Rack::Cors do
+# Be sure to restart your server when you modify this file.
+
+# Avoid CORS issues when API is called from the frontend app.
+# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
+
+# Read more: https://github.com/cyu/rack-cors
+
+Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins "*"
resource "/api/openid_connect/user_info", methods: %i(get post)
@@ -6,6 +13,5 @@ Rails.application.config.middleware.insert 0, Rack::Cors do
resource "/.well-known/host-meta"
resource "/.well-known/webfinger"
resource "/.well-known/openid-configuration"
- resource "/webfinger"
end
end
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
index d08250390..9d07a384f 100644
--- a/config/initializers/filter_parameter_logging.rb
+++ b/config/initializers/filter_parameter_logging.rb
@@ -1,4 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
-Rails.application.config.filter_parameters += %i(password message text bio)
+Rails.application.config.filter_parameters += %i[password message text bio]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
new file mode 100644
index 000000000..ac033bf9d
--- /dev/null
+++ b/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
new file mode 100644
index 000000000..dc1899682
--- /dev/null
+++ b/config/initializers/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
index ddd9dd5ab..c72a96765 100644
--- a/config/initializers/wrap_parameters.rb
+++ b/config/initializers/wrap_parameters.rb
@@ -5,10 +5,10 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
- wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
+ wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
ActiveSupport.on_load(:active_record) do
- self.include_root_in_json = true
+ self.include_root_in_json = true
end
diff --git a/config/routes.rb b/config/routes.rb
index 355154a6f..b7d4c69ab 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -6,7 +6,8 @@ require "sidekiq/web"
require "sidekiq/cron/web"
Sidekiq::Web.set :sessions, false # disable rack session cookie
-Diaspora::Application.routes.draw do
+Rails.application.routes.draw do
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :report, except: %i(edit new show)
diff --git a/config/spring.rb b/config/spring.rb
new file mode 100644
index 000000000..0598e88c3
--- /dev/null
+++ b/config/spring.rb
@@ -0,0 +1,6 @@
+%w[
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+].each {|path| Spring.watch(path) }
diff --git a/db/migrate/0000_create_schema.rb b/db/migrate/0000_create_schema.rb
index 97fcc3da6..a6393fd40 100644
--- a/db/migrate/0000_create_schema.rb
+++ b/db/migrate/0000_create_schema.rb
@@ -1,488 +1,492 @@
-class CreateSchema < ActiveRecord::Migration
- create_table "account_deletions", :force => true do |t|
- t.string "diaspora_handle"
- t.integer "person_id"
+class CreateSchema < ActiveRecord::Migration[4.2]
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/LineLength, Layout/ExtraSpacing
+ def up
+ create_table :account_deletions do |t|
+ t.string :diaspora_handle
+ t.integer :person_id
+ end
+
+ create_table :aspect_memberships do |t|
+ t.integer :aspect_id, null: false
+ t.integer :contact_id, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ add_index :aspect_memberships, %i[aspect_id contact_id], name: :index_aspect_memberships_on_aspect_id_and_contact_id, unique: true
+ add_index :aspect_memberships, [:aspect_id], name: :index_aspect_memberships_on_aspect_id
+ add_index :aspect_memberships, [:contact_id], name: :index_aspect_memberships_on_contact_id
+
+ create_table :aspect_visibilities do |t|
+ t.integer :shareable_id, null: false
+ t.integer :aspect_id, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.string :shareable_type, default: "Post", null: false
+ end
+
+ add_index :aspect_visibilities, [:aspect_id], name: :index_aspect_visibilities_on_aspect_id
+ add_index :aspect_visibilities, %i[shareable_id shareable_type aspect_id], name: :shareable_and_aspect_id, length: {shareable_type: 189}, using: :btree
+ add_index :aspect_visibilities, %i[shareable_id shareable_type], name: :index_aspect_visibilities_on_shareable_id_and_shareable_type, length: {shareable_type: 190}, using: :btree
+
+ create_table :aspects do |t|
+ t.string :name, null: false
+ t.integer :user_id, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.boolean :contacts_visible, default: true, null: false
+ t.integer :order_id
+ end
+
+ add_index :aspects, %i[user_id contacts_visible], name: :index_aspects_on_user_id_and_contacts_visible
+ add_index :aspects, [:user_id], name: :index_aspects_on_user_id
+
+ create_table :blocks do |t|
+ t.integer :user_id
+ t.integer :person_id
+ end
+
+ create_table :comments do |t|
+ t.text :text, null: false
+ t.integer :commentable_id, null: false
+ t.integer :author_id, null: false
+ t.string :guid, null: false
+ t.text :author_signature
+ t.text :parent_author_signature
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.integer :likes_count, default: 0, null: false
+ t.string :commentable_type, limit: 60, default: "Post", null: false
+ end
+
+ add_index :comments, [:author_id], name: :index_comments_on_person_id
+ add_index :comments, %i[commentable_id commentable_type], name: :index_comments_on_commentable_id_and_commentable_type
+ add_index :comments, [:guid], name: :index_comments_on_guid, length: {guid: 191}, using: :btree, unique: true
+
+ create_table :contacts do |t|
+ t.integer :user_id, null: false
+ t.integer :person_id, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.boolean :sharing, default: false, null: false
+ t.boolean :receiving, default: false, null: false
+ end
+
+ add_index :contacts, [:person_id], name: :index_contacts_on_person_id
+ add_index :contacts, %i[user_id person_id], name: :index_contacts_on_user_id_and_person_id, unique: true
+
+ create_table :conversation_visibilities do |t|
+ t.integer :conversation_id, null: false
+ t.integer :person_id, null: false
+ t.integer :unread, default: 0, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ add_index :conversation_visibilities, %i[conversation_id person_id], name: :index_conversation_visibilities_usefully, unique: true
+ add_index :conversation_visibilities, [:conversation_id], name: :index_conversation_visibilities_on_conversation_id
+ add_index :conversation_visibilities, [:person_id], name: :index_conversation_visibilities_on_person_id
+
+ create_table :conversations do |t|
+ t.string :subject
+ t.string :guid, null: false
+ t.integer :author_id, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ add_index :conversations, [:author_id], name: :conversations_author_id_fk
+
+ create_table :invitation_codes do |t|
+ t.string :token
+ t.integer :user_id
+ t.integer :count
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ create_table :invitations do |t|
+ t.text :message
+ t.integer :sender_id
+ t.integer :recipient_id
+ t.integer :aspect_id
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.string :service
+ t.string :identifier
+ t.boolean :admin, default: false
+ t.string :language, default: "en"
+ end
+
+ add_index :invitations, [:aspect_id], name: :index_invitations_on_aspect_id
+ add_index :invitations, [:recipient_id], name: :index_invitations_on_recipient_id
+ add_index :invitations, [:sender_id], name: :index_invitations_on_sender_id
+
+ create_table :likes do |t|
+ t.boolean :positive, default: true
+ t.integer :target_id
+ t.integer :author_id
+ t.string :guid
+ t.text :author_signature
+ t.text :parent_author_signature
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.string :target_type, limit: 60, null: false
+ end
+
+ add_index :likes, [:author_id], name: :likes_author_id_fk
+ add_index :likes, [:guid], name: :index_likes_on_guid, length: {guid: 191}, using: :btree, unique: true
+ add_index :likes, %i[target_id author_id target_type], name: :index_likes_on_target_id_and_author_id_and_target_type, unique: true
+ add_index :likes, [:target_id], name: :index_likes_on_post_id
+
+ create_table :locations do |t|
+ t.string :address
+ t.string :lat
+ t.string :lng
+ t.integer :status_message_id
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ create_table :mentions do |t|
+ t.integer :post_id, null: false
+ t.integer :person_id, null: false
+ end
+
+ add_index :mentions, %i[person_id post_id], name: :index_mentions_on_person_id_and_post_id, unique: true
+ add_index :mentions, [:person_id], name: :index_mentions_on_person_id
+ add_index :mentions, [:post_id], name: :index_mentions_on_post_id
+
+ create_table :messages do |t|
+ t.integer :conversation_id, null: false
+ t.integer :author_id, null: false
+ t.string :guid, null: false
+ t.text :text, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.text :author_signature
+ t.text :parent_author_signature
+ end
+
+ add_index :messages, [:author_id], name: :index_messages_on_author_id
+ add_index :messages, [:conversation_id], name: :messages_conversation_id_fk
+
+ create_table :notification_actors do |t|
+ t.integer :notification_id
+ t.integer :person_id
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ add_index :notification_actors, %i[notification_id person_id], name: :index_notification_actors_on_notification_id_and_person_id, unique: true
+ add_index :notification_actors, [:notification_id], name: :index_notification_actors_on_notification_id
+ add_index :notification_actors, [:person_id], name: :index_notification_actors_on_person_id
+
+ create_table :notifications do |t|
+ t.string :target_type
+ t.integer :target_id
+ t.integer :recipient_id, null: false
+ t.boolean :unread, default: true, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.string :type
+ end
+
+ add_index :notifications, [:recipient_id], name: :index_notifications_on_recipient_id
+ add_index :notifications, [:target_id], name: :index_notifications_on_target_id
+ add_index :notifications, %i[target_type target_id], name: :index_notifications_on_target_type_and_target_id, length: {target_type: 190}, using: :btree
+
+ create_table :o_embed_caches do |t|
+ t.string :url, limit: 1024, null: false
+ t.text :data, null: false
+ end
+
+ add_index :o_embed_caches, [:url], name: :index_o_embed_caches_on_url, length: {url: 191}, using: :btree
+
+ create_table :participations do |t|
+ t.string :guid
+ t.integer :target_id
+ t.string :target_type, limit: 60, null: false
+ t.integer :author_id
+ t.text :author_signature
+ t.text :parent_author_signature
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ add_index :participations, [:guid], name: :index_participations_on_guid, length: {guid: 191}, using: :btree
+ add_index :participations, %i[target_id target_type author_id], name: :index_participations_on_target_id_and_target_type_and_author_id
+
+ create_table :people do |t|
+ t.string :guid, null: false
+ t.text :url, null: false
+ t.string :diaspora_handle, null: false
+ t.text :serialized_public_key, null: false
+ t.integer :owner_id
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.boolean :closed_account, default: false
+ t.integer :fetch_status, default: 0
+ end
+
+ add_index :people, [:diaspora_handle], name: :index_people_on_diaspora_handle, unique: true, length: {diaspora_handle: 191}
+ add_index :people, [:guid], name: :index_people_on_guid, length: {guid: 191}, using: :btree, unique: true
+ add_index :people, [:owner_id], name: :index_people_on_owner_id, unique: true
+
+ create_table :photos do |t|
+ t.integer :tmp_old_id
+ t.integer :author_id, null: false
+ t.boolean :public, default: false, null: false
+ t.string :diaspora_handle
+ t.string :guid, null: false
+ t.boolean :pending, default: false, null: false
+ t.text :text
+ t.text :remote_photo_path
+ t.string :remote_photo_name
+ t.string :random_string
+ t.string :processed_image
+ t.datetime :created_at
+ t.datetime :updated_at
+ t.string :unprocessed_image
+ t.string :status_message_guid
+ t.integer :comments_count
+ t.integer :height
+ t.integer :width
+ end
+
+ add_index :photos, [:status_message_guid], name: :index_photos_on_status_message_guid, length: {status_message_guid: 191}, using: :btree
+
+ create_table :pods do |t|
+ t.string :host
+ t.boolean :ssl
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ create_table :posts do |t|
+ t.integer :author_id, null: false
+ t.boolean :public, default: false, null: false
+ t.string :diaspora_handle
+ t.string :guid, null: false
+ t.boolean :pending, default: false, null: false
+ t.string :type, limit: 40, null: false
+ t.text :text
+ t.text :remote_photo_path
+ t.string :remote_photo_name
+ t.string :random_string
+ t.string :processed_image
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.string :unprocessed_image
+ t.string :object_url
+ t.string :image_url
+ t.integer :image_height
+ t.integer :image_width
+ t.string :provider_display_name
+ t.string :actor_url
+ t.string :objectId
+ t.string :root_guid, limit: 30
+ t.string :status_message_guid
+ t.integer :likes_count, default: 0
+ t.integer :comments_count, default: 0
+ t.integer :o_embed_cache_id
+ t.integer :reshares_count, default: 0
+ t.datetime :interacted_at
+ t.string :frame_name
+ t.boolean :favorite, default: false
+ end
+
+ add_index :posts, %i[author_id root_guid], name: :index_posts_on_author_id_and_root_guid, length: {root_guid: 30}, using: :btree, unique: true
+ add_index :posts, [:author_id], name: :index_posts_on_person_id
+ add_index :posts, [:guid], name: :index_posts_on_guid, length: {guid: 191}, using: :btree, unique: true
+ add_index :posts, %i[id type created_at], name: :index_posts_on_id_and_type_and_created_at
+ add_index :posts, [:root_guid], name: :index_posts_on_root_guid, length: {root_guid: 30}
+ add_index :posts, %i[status_message_guid pending], name: :index_posts_on_status_message_guid_and_pending, length: {status_message_guid: 190}, using: :btree
+ add_index :posts, [:status_message_guid], name: :index_posts_on_status_message_guid, length: {status_message_guid: 191}, using: :btree
+ add_index :posts, %i[type pending id], name: :index_posts_on_type_and_pending_and_id
+
+ create_table :profiles do |t|
+ t.string :diaspora_handle
+ t.string :first_name, limit: 127
+ t.string :last_name, limit: 127
+ t.string :image_url
+ t.string :image_url_small
+ t.string :image_url_medium
+ t.date :birthday
+ t.string :gender
+ t.text :bio
+ t.boolean :searchable, default: true, null: false
+ t.integer :person_id, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.string :location
+ t.string :full_name, limit: 70
+ t.boolean :nsfw, default: false
+ end
+
+ add_index :profiles, %i[full_name searchable], name: :index_profiles_on_full_name_and_searchable
+ add_index :profiles, [:full_name], name: :index_profiles_on_full_name
+ add_index :profiles, [:person_id], name: :index_profiles_on_person_id
+
+ create_table :rails_admin_histories do |t|
+ t.text :message
+ t.string :username
+ t.integer :item
+ t.string :table
+ t.integer :month, limit: 2
+ t.integer :year, limit: 8
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ add_index :rails_admin_histories, %i[item table month year], name: :index_rails_admin_histories, length: {table: 188}
+
+ create_table :roles do |t|
+ t.integer :person_id
+ t.string :name
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ create_table :services do |t|
+ t.string :type, limit: 127, null: false
+ t.integer :user_id, null: false
+ t.string :uid, limit: 127
+ t.string :access_token
+ t.string :access_secret
+ t.string :nickname
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ add_index :services, %i[type uid], name: :index_services_on_type_and_uid, length: {type: 64, uid: 127}, using: :btree
+ add_index :services, [:user_id], name: :index_services_on_user_id
+
+ create_table :share_visibilities do |t|
+ t.integer :shareable_id, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.boolean :hidden, default: false, null: false
+ t.integer :contact_id, null: false
+ t.string :shareable_type, limit: 60, default: "Post", null: false
+ end
+
+ add_index :share_visibilities, [:contact_id], name: :index_post_visibilities_on_contact_id
+ add_index :share_visibilities, %i[shareable_id shareable_type contact_id], name: :shareable_and_contact_id
+ add_index :share_visibilities, %i[shareable_id shareable_type hidden contact_id], name: :shareable_and_hidden_and_contact_id
+ add_index :share_visibilities, [:shareable_id], name: :index_post_visibilities_on_post_id
+
+ create_table :tag_followings do |t|
+ t.integer :tag_id, null: false
+ t.integer :user_id, null: false
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ add_index :tag_followings, %i[tag_id user_id], name: :index_tag_followings_on_tag_id_and_user_id, unique: true
+ add_index :tag_followings, [:tag_id], name: :index_tag_followings_on_tag_id
+ add_index :tag_followings, [:user_id], name: :index_tag_followings_on_user_id
+
+ create_table :taggings do |t|
+ t.integer :tag_id
+ t.integer :taggable_id
+ t.string :taggable_type, limit: 127
+ t.integer :tagger_id
+ t.string :tagger_type, limit: 127
+ t.string :context, limit: 127
+ t.datetime :created_at
+ end
+
+ add_index :taggings, [:created_at], name: :index_taggings_on_created_at
+ add_index :taggings, [:tag_id], name: :index_taggings_on_tag_id
+ add_index :taggings, %i[taggable_id taggable_type context], name: :index_taggings_on_taggable_id_and_taggable_type_and_context, length: {taggable_type: 95, context: 95}, using: :btree
+ add_index :taggings, %i[taggable_id taggable_type tag_id], name: :index_taggings_uniquely, unique: true
+
+ create_table :tags do |t|
+ t.string :name
+ end
+
+ add_index :tags, [:name], name: :index_tags_on_name, unique: true, length: {name: 191}
+
+ create_table :user_preferences do |t|
+ t.string :email_type
+ t.integer :user_id
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ end
+
+ create_table :users do |t|
+ t.string :username
+ t.text :serialized_private_key
+ t.boolean :getting_started, default: true, null: false
+ t.boolean :disable_mail, default: false, null: false
+ t.string :language
+ t.string :email, default: "", null: false
+ t.string :encrypted_password, default: "", null: false
+ t.string :invitation_token, limit: 60
+ t.datetime :invitation_sent_at
+ t.string :reset_password_token
+ t.datetime :remember_created_at
+ t.integer :sign_in_count, default: 0
+ t.datetime :current_sign_in_at
+ t.datetime :last_sign_in_at
+ t.string :current_sign_in_ip
+ t.string :last_sign_in_ip
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+ t.string :invitation_service, limit: 127
+ t.string :invitation_identifier, limit: 127
+ t.integer :invitation_limit
+ t.integer :invited_by_id
+ t.string :invited_by_type
+ t.string :authentication_token, limit: 30
+ t.string :unconfirmed_email
+ t.string :confirm_email_token, limit: 30
+ t.datetime :locked_at
+ t.boolean :show_community_spotlight_in_stream, default: true, null: false
+ t.boolean :auto_follow_back, default: false
+ t.integer :auto_follow_back_aspect_id
+ t.text :hidden_shareables
+ t.datetime :reset_password_sent_at
+ end
+
+ add_index :users, [:authentication_token], name: :index_users_on_authentication_token, unique: true
+ add_index :users, [:email], name: :index_users_on_email, length: {email: 191}
+ add_index :users, %i[invitation_service invitation_identifier], name: :index_users_on_invitation_service_and_invitation_identifier, length: {invitation_service: 64, invitation_identifier: 127}, using: :btree, unique: true
+ add_index :users, [:invitation_token], name: :index_users_on_invitation_token
+ add_index :users, [:username], name: :index_users_on_username, length: {username: 191}, using: :btree, unique: true
+
+ add_foreign_key :aspect_memberships, :aspects, name: :aspect_memberships_aspect_id_fk, on_delete: :cascade
+ add_foreign_key :aspect_memberships, :contacts, name: :aspect_memberships_contact_id_fk, on_delete: :cascade
+
+ add_foreign_key :aspect_visibilities, :aspects, name: :aspect_visibilities_aspect_id_fk, on_delete: :cascade
+
+ add_foreign_key :comments, :people, name: :comments_author_id_fk, column: :author_id, on_delete: :cascade
+
+ add_foreign_key :contacts, :people, name: :contacts_person_id_fk, on_delete: :cascade
+
+ add_foreign_key :conversation_visibilities, :conversations, name: :conversation_visibilities_conversation_id_fk, on_delete: :cascade
+ add_foreign_key :conversation_visibilities, :people, name: :conversation_visibilities_person_id_fk, on_delete: :cascade
+
+ add_foreign_key :conversations, :people, name: :conversations_author_id_fk, column: :author_id, on_delete: :cascade
+
+ add_foreign_key :invitations, :users, name: :invitations_recipient_id_fk, column: :recipient_id, on_delete: :cascade
+ add_foreign_key :invitations, :users, name: :invitations_sender_id_fk, column: :sender_id, on_delete: :cascade
+
+ add_foreign_key :likes, :people, name: :likes_author_id_fk, column: :author_id, on_delete: :cascade
+
+ add_foreign_key :messages, :conversations, name: :messages_conversation_id_fk, on_delete: :cascade
+ add_foreign_key :messages, :people, name: :messages_author_id_fk, column: :author_id, on_delete: :cascade
+
+ add_foreign_key :notification_actors, :notifications, name: :notification_actors_notification_id_fk, on_delete: :cascade
+
+ add_foreign_key :posts, :people, name: :posts_author_id_fk, column: :author_id, on_delete: :cascade
+
+ add_foreign_key :profiles, :people, name: :profiles_person_id_fk, on_delete: :cascade
+
+ add_foreign_key :services, :users, name: :services_user_id_fk, on_delete: :cascade
+
+ add_foreign_key :share_visibilities, :contacts, name: :post_visibilities_contact_id_fk, on_delete: :cascade
end
-
- create_table "aspect_memberships", :force => true do |t|
- t.integer "aspect_id", :null => false
- t.integer "contact_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "aspect_memberships", ["aspect_id", "contact_id"], :name => "index_aspect_memberships_on_aspect_id_and_contact_id", :unique => true
- add_index "aspect_memberships", ["aspect_id"], :name => "index_aspect_memberships_on_aspect_id"
- add_index "aspect_memberships", ["contact_id"], :name => "index_aspect_memberships_on_contact_id"
-
- create_table "aspect_visibilities", :force => true do |t|
- t.integer "shareable_id", :null => false
- t.integer "aspect_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "shareable_type", :default => "Post", :null => false
- end
-
- add_index "aspect_visibilities", ["aspect_id"], :name => "index_aspect_visibilities_on_aspect_id"
- add_index 'aspect_visibilities', ["shareable_id", "shareable_type", "aspect_id"], :name => 'shareable_and_aspect_id', length: {"shareable_type"=>189}, :using => :btree
- add_index 'aspect_visibilities', ["shareable_id", "shareable_type"], :name => 'index_aspect_visibilities_on_shareable_id_and_shareable_type', length: {"shareable_type"=>190}, :using => :btree
-
- create_table "aspects", :force => true do |t|
- t.string "name", :null => false
- t.integer "user_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.boolean "contacts_visible", :default => true, :null => false
- t.integer "order_id"
- end
-
- add_index "aspects", ["user_id", "contacts_visible"], :name => "index_aspects_on_user_id_and_contacts_visible"
- add_index "aspects", ["user_id"], :name => "index_aspects_on_user_id"
-
- create_table "blocks", :force => true do |t|
- t.integer "user_id"
- t.integer "person_id"
- end
-
- create_table "comments", :force => true do |t|
- t.text "text", :null => false
- t.integer "commentable_id", :null => false
- t.integer "author_id", :null => false
- t.string "guid", :null => false
- t.text "author_signature"
- t.text "parent_author_signature"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.integer "likes_count", :default => 0, :null => false
- t.string "commentable_type", :limit => 60, :default => "Post", :null => false
- end
-
- add_index "comments", ["author_id"], :name => "index_comments_on_person_id"
- add_index "comments", ["commentable_id", "commentable_type"], :name => "index_comments_on_commentable_id_and_commentable_type"
- add_index 'comments', ["guid"], :name => 'index_comments_on_guid', length: {"guid"=>191}, :using => :btree, :unique => true
-
- create_table "contacts", :force => true do |t|
- t.integer "user_id", :null => false
- t.integer "person_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.boolean "sharing", :default => false, :null => false
- t.boolean "receiving", :default => false, :null => false
- end
-
- add_index "contacts", ["person_id"], :name => "index_contacts_on_person_id"
- add_index "contacts", ["user_id", "person_id"], :name => "index_contacts_on_user_id_and_person_id", :unique => true
-
- create_table "conversation_visibilities", :force => true do |t|
- t.integer "conversation_id", :null => false
- t.integer "person_id", :null => false
- t.integer "unread", :default => 0, :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "conversation_visibilities", ["conversation_id", "person_id"], :name => "index_conversation_visibilities_usefully", :unique => true
- add_index "conversation_visibilities", ["conversation_id"], :name => "index_conversation_visibilities_on_conversation_id"
- add_index "conversation_visibilities", ["person_id"], :name => "index_conversation_visibilities_on_person_id"
-
- create_table "conversations", :force => true do |t|
- t.string "subject"
- t.string "guid", :null => false
- t.integer "author_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "conversations", ["author_id"], :name => "conversations_author_id_fk"
-
- create_table "invitation_codes", :force => true do |t|
- t.string "token"
- t.integer "user_id"
- t.integer "count"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- create_table "invitations", :force => true do |t|
- t.text "message"
- t.integer "sender_id"
- t.integer "recipient_id"
- t.integer "aspect_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "service"
- t.string "identifier"
- t.boolean "admin", :default => false
- t.string "language", :default => "en"
- end
-
- add_index "invitations", ["aspect_id"], :name => "index_invitations_on_aspect_id"
- add_index "invitations", ["recipient_id"], :name => "index_invitations_on_recipient_id"
- add_index "invitations", ["sender_id"], :name => "index_invitations_on_sender_id"
-
- create_table "likes", :force => true do |t|
- t.boolean "positive", :default => true
- t.integer "target_id"
- t.integer "author_id"
- t.string "guid"
- t.text "author_signature"
- t.text "parent_author_signature"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "target_type", :limit => 60, :null => false
- end
-
- add_index "likes", ["author_id"], :name => "likes_author_id_fk"
- add_index 'likes', ["guid"], :name => 'index_likes_on_guid', length: {"guid"=>191}, :using => :btree, :unique => true
- add_index "likes", ["target_id", "author_id", "target_type"], :name => "index_likes_on_target_id_and_author_id_and_target_type", :unique => true
- add_index "likes", ["target_id"], :name => "index_likes_on_post_id"
-
- create_table "locations", :force => true do |t|
- t.string "address"
- t.string "lat"
- t.string "lng"
- t.integer "status_message_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- create_table "mentions", :force => true do |t|
- t.integer "post_id", :null => false
- t.integer "person_id", :null => false
- end
-
- add_index "mentions", ["person_id", "post_id"], :name => "index_mentions_on_person_id_and_post_id", :unique => true
- add_index "mentions", ["person_id"], :name => "index_mentions_on_person_id"
- add_index "mentions", ["post_id"], :name => "index_mentions_on_post_id"
-
- create_table "messages", :force => true do |t|
- t.integer "conversation_id", :null => false
- t.integer "author_id", :null => false
- t.string "guid", :null => false
- t.text "text", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.text "author_signature"
- t.text "parent_author_signature"
- end
-
- add_index "messages", ["author_id"], :name => "index_messages_on_author_id"
- add_index "messages", ["conversation_id"], :name => "messages_conversation_id_fk"
-
- create_table "notification_actors", :force => true do |t|
- t.integer "notification_id"
- t.integer "person_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "notification_actors", ["notification_id", "person_id"], :name => "index_notification_actors_on_notification_id_and_person_id", :unique => true
- add_index "notification_actors", ["notification_id"], :name => "index_notification_actors_on_notification_id"
- add_index "notification_actors", ["person_id"], :name => "index_notification_actors_on_person_id"
-
- create_table "notifications", :force => true do |t|
- t.string "target_type"
- t.integer "target_id"
- t.integer "recipient_id", :null => false
- t.boolean "unread", :default => true, :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "type"
- end
-
- add_index "notifications", ["recipient_id"], :name => "index_notifications_on_recipient_id"
- add_index "notifications", ["target_id"], :name => "index_notifications_on_target_id"
- add_index 'notifications', ["target_type", "target_id"], name: 'index_notifications_on_target_type_and_target_id', length: {"target_type"=>190}, using: :btree
-
- create_table "o_embed_caches", :force => true do |t|
- t.string "url", :limit => 1024, :null => false
- t.text "data", :null => false
- end
-
- add_index "o_embed_caches", ["url"], :name => "index_o_embed_caches_on_url", :length => {"url"=> 191}, using: :btree
-
- create_table "participations", :force => true do |t|
- t.string "guid"
- t.integer "target_id"
- t.string "target_type", :limit => 60, :null => false
- t.integer "author_id"
- t.text "author_signature"
- t.text "parent_author_signature"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index 'participations', ["guid"], :name => 'index_participations_on_guid', length: {"guid"=>191}, :using => :btree
- add_index "participations", ["target_id", "target_type", "author_id"], :name => "index_participations_on_target_id_and_target_type_and_author_id"
-
- create_table "people", :force => true do |t|
- t.string "guid", :null => false
- t.text "url", :null => false
- t.string "diaspora_handle", :null => false
- t.text "serialized_public_key", :null => false
- t.integer "owner_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.boolean "closed_account", :default => false
- t.integer "fetch_status", :default => 0
- end
-
- add_index "people", ["diaspora_handle"], :name => "index_people_on_diaspora_handle", :unique => true, :length => {"diaspora_handle" => 191}
- add_index 'people', ["guid"], :name => 'index_people_on_guid', length: {"guid"=>191}, :using => :btree, :unique => true
- add_index "people", ["owner_id"], :name => "index_people_on_owner_id", :unique => true
-
- create_table "photos", :force => true do |t|
- t.integer "tmp_old_id"
- t.integer "author_id", :null => false
- t.boolean "public", :default => false, :null => false
- t.string "diaspora_handle"
- t.string "guid", :null => false
- t.boolean "pending", :default => false, :null => false
- t.text "text"
- t.text "remote_photo_path"
- t.string "remote_photo_name"
- t.string "random_string"
- t.string "processed_image"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "unprocessed_image"
- t.string "status_message_guid"
- t.integer "comments_count"
- t.integer "height"
- t.integer "width"
- end
-
- add_index 'photos', ["status_message_guid"], :name => 'index_photos_on_status_message_guid', length: {"status_message_guid"=>191}, :using => :btree
-
- create_table "pods", :force => true do |t|
- t.string "host"
- t.boolean "ssl"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- create_table "posts", :force => true do |t|
- t.integer "author_id", :null => false
- t.boolean "public", :default => false, :null => false
- t.string "diaspora_handle"
- t.string "guid", :null => false
- t.boolean "pending", :default => false, :null => false
- t.string "type", :limit => 40, :null => false
- t.text "text"
- t.text "remote_photo_path"
- t.string "remote_photo_name"
- t.string "random_string"
- t.string "processed_image"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "unprocessed_image"
- t.string "object_url"
- t.string "image_url"
- t.integer "image_height"
- t.integer "image_width"
- t.string "provider_display_name"
- t.string "actor_url"
- t.string "objectId"
- t.string "root_guid", :limit => 30
- t.string "status_message_guid"
- t.integer "likes_count", :default => 0
- t.integer "comments_count", :default => 0
- t.integer "o_embed_cache_id"
- t.integer "reshares_count", :default => 0
- t.datetime "interacted_at"
- t.string "frame_name"
- t.boolean "favorite", :default => false
- end
-
- add_index 'posts', ["author_id", "root_guid"], :name => 'index_posts_on_author_id_and_root_guid', length: {"root_guid"=>30}, :using => :btree, :unique => true
- add_index "posts", ["author_id"], :name => "index_posts_on_person_id"
- add_index 'posts', ["guid"], :name => 'index_posts_on_guid', length: {"guid"=>191}, :using => :btree, :unique => true
- add_index "posts", ["id", "type", "created_at"], :name => "index_posts_on_id_and_type_and_created_at"
- add_index 'posts', ["root_guid"], :name => 'index_posts_on_root_guid', length: {"root_guid"=>30}
- add_index 'posts', ["status_message_guid", "pending"], :name => 'index_posts_on_status_message_guid_and_pending', length: {"status_message_guid"=>190}, :using => :btree
- add_index 'posts', ["status_message_guid"], :name => 'index_posts_on_status_message_guid', length: {"status_message_guid"=>191}, :using => :btree
- add_index "posts", ["type", "pending", "id"], :name => "index_posts_on_type_and_pending_and_id"
-
- create_table "profiles", :force => true do |t|
- t.string "diaspora_handle"
- t.string "first_name", :limit => 127
- t.string "last_name", :limit => 127
- t.string "image_url"
- t.string "image_url_small"
- t.string "image_url_medium"
- t.date "birthday"
- t.string "gender"
- t.text "bio"
- t.boolean "searchable", :default => true, :null => false
- t.integer "person_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "location"
- t.string "full_name", :limit => 70
- t.boolean "nsfw", :default => false
- end
-
- add_index "profiles", ["full_name", "searchable"], :name => "index_profiles_on_full_name_and_searchable"
- add_index "profiles", ["full_name"], :name => "index_profiles_on_full_name"
- add_index "profiles", ["person_id"], :name => "index_profiles_on_person_id"
-
- create_table "rails_admin_histories", :force => true do |t|
- t.text "message"
- t.string "username"
- t.integer "item"
- t.string "table"
- t.integer "month", :limit => 2
- t.integer "year", :limit => 8
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories", :length => {"table" => 188}
-
- create_table "roles", :force => true do |t|
- t.integer "person_id"
- t.string "name"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- create_table "services", :force => true do |t|
- t.string "type", :limit => 127, :null => false
- t.integer "user_id", :null => false
- t.string "uid", :limit => 127
- t.string "access_token"
- t.string "access_secret"
- t.string "nickname"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index 'services', ["type", "uid"], :name => 'index_services_on_type_and_uid', length: {"type"=>64, "uid"=>127}, :using => :btree
- add_index "services", ["user_id"], :name => "index_services_on_user_id"
-
- create_table "share_visibilities", :force => true do |t|
- t.integer "shareable_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.boolean "hidden", :default => false, :null => false
- t.integer "contact_id", :null => false
- t.string "shareable_type", :limit => 60, :default => "Post", :null => false
- end
-
- add_index "share_visibilities", ["contact_id"], :name => "index_post_visibilities_on_contact_id"
- add_index "share_visibilities", ["shareable_id", "shareable_type", "contact_id"], :name => "shareable_and_contact_id"
- add_index "share_visibilities", ["shareable_id", "shareable_type", "hidden", "contact_id"], :name => "shareable_and_hidden_and_contact_id"
- add_index "share_visibilities", ["shareable_id"], :name => "index_post_visibilities_on_post_id"
-
- create_table "tag_followings", :force => true do |t|
- t.integer "tag_id", :null => false
- t.integer "user_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "tag_followings", ["tag_id", "user_id"], :name => "index_tag_followings_on_tag_id_and_user_id", :unique => true
- add_index "tag_followings", ["tag_id"], :name => "index_tag_followings_on_tag_id"
- add_index "tag_followings", ["user_id"], :name => "index_tag_followings_on_user_id"
-
- create_table "taggings", :force => true do |t|
- t.integer "tag_id"
- t.integer "taggable_id"
- t.string "taggable_type", :limit => 127
- t.integer "tagger_id"
- t.string "tagger_type", :limit => 127
- t.string "context", :limit => 127
- t.datetime "created_at"
- end
-
- add_index "taggings", ["created_at"], :name => "index_taggings_on_created_at"
- add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
- add_index 'taggings', ["taggable_id", "taggable_type", "context"], :name => 'index_taggings_on_taggable_id_and_taggable_type_and_context', length: {"taggable_type"=>95, "context"=>95}, :using => :btree
- add_index "taggings", ["taggable_id", "taggable_type", "tag_id"], :name => "index_taggings_uniquely", :unique => true
-
- create_table "tags", :force => true do |t|
- t.string "name"
- end
-
- add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true, :length => {"name" => 191}
-
- create_table "user_preferences", :force => true do |t|
- t.string "email_type"
- t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- create_table "users", :force => true do |t|
- t.string "username"
- t.text "serialized_private_key"
- t.boolean "getting_started", :default => true, :null => false
- t.boolean "disable_mail", :default => false, :null => false
- t.string "language"
- t.string "email", :default => "", :null => false
- t.string "encrypted_password", :default => "", :null => false
- t.string "invitation_token", :limit => 60
- t.datetime "invitation_sent_at"
- t.string "reset_password_token"
- t.datetime "remember_created_at"
- t.integer "sign_in_count", :default => 0
- t.datetime "current_sign_in_at"
- t.datetime "last_sign_in_at"
- t.string "current_sign_in_ip"
- t.string "last_sign_in_ip"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "invitation_service", :limit => 127
- t.string "invitation_identifier", :limit => 127
- t.integer "invitation_limit"
- t.integer "invited_by_id"
- t.string "invited_by_type"
- t.string "authentication_token", :limit => 30
- t.string "unconfirmed_email"
- t.string "confirm_email_token", :limit => 30
- t.datetime "locked_at"
- t.boolean "show_community_spotlight_in_stream", :default => true, :null => false
- t.boolean "auto_follow_back", :default => false
- t.integer "auto_follow_back_aspect_id"
- t.text "hidden_shareables"
- t.datetime "reset_password_sent_at"
- end
-
- add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true
- add_index "users", ["email"], :name => "index_users_on_email", length: {"email" => "191"}
- add_index 'users', ["invitation_service", "invitation_identifier"], :name => 'index_users_on_invitation_service_and_invitation_identifier', length: {"invitation_service"=>64, "invitation_identifier"=>127}, :using => :btree, :unique => true
- add_index "users", ["invitation_token"], :name => "index_users_on_invitation_token"
- add_index 'users', ["username"], :name => 'index_users_on_username', length: {"username"=>191}, :using => :btree, :unique => true
-
- add_foreign_key "aspect_memberships", "aspects", name: "aspect_memberships_aspect_id_fk", on_delete: :cascade
- add_foreign_key "aspect_memberships", "contacts", name: "aspect_memberships_contact_id_fk", on_delete: :cascade
-
- add_foreign_key "aspect_visibilities", "aspects", name: "aspect_visibilities_aspect_id_fk", on_delete: :cascade
-
- add_foreign_key "comments", "people", name: "comments_author_id_fk", column: "author_id", on_delete: :cascade
-
- add_foreign_key "contacts", "people", name: "contacts_person_id_fk", on_delete: :cascade
-
- add_foreign_key "conversation_visibilities", "conversations", name: "conversation_visibilities_conversation_id_fk", on_delete: :cascade
- add_foreign_key "conversation_visibilities", "people", name: "conversation_visibilities_person_id_fk", on_delete: :cascade
-
- add_foreign_key "conversations", "people", name: "conversations_author_id_fk", column: "author_id", on_delete: :cascade
-
- add_foreign_key "invitations", "users", name: "invitations_recipient_id_fk", column: "recipient_id", on_delete: :cascade
- add_foreign_key "invitations", "users", name: "invitations_sender_id_fk", column: "sender_id", on_delete: :cascade
-
- add_foreign_key "likes", "people", name: "likes_author_id_fk", column: "author_id", on_delete: :cascade
-
- add_foreign_key "messages", "conversations", name: "messages_conversation_id_fk", on_delete: :cascade
- add_foreign_key "messages", "people", name: "messages_author_id_fk", column: "author_id", on_delete: :cascade
-
- add_foreign_key "notification_actors", "notifications", name: "notification_actors_notification_id_fk", on_delete: :cascade
-
- add_foreign_key "posts", "people", name: "posts_author_id_fk", column: "author_id", on_delete: :cascade
-
- add_foreign_key "profiles", "people", name: "profiles_person_id_fk", on_delete: :cascade
-
- add_foreign_key "services", "users", name: "services_user_id_fk", on_delete: :cascade
-
- add_foreign_key "share_visibilities", "contacts", name: "post_visibilities_contact_id_fk", on_delete: :cascade
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/LineLength, Layout/ExtraSpacing
end
diff --git a/db/migrate/20130207231310_add_facebook_id_to_post.rb b/db/migrate/20130207231310_add_facebook_id_to_post.rb
index df888dcca..f559f46a7 100644
--- a/db/migrate/20130207231310_add_facebook_id_to_post.rb
+++ b/db/migrate/20130207231310_add_facebook_id_to_post.rb
@@ -1,4 +1,4 @@
-class AddFacebookIdToPost < ActiveRecord::Migration
+class AddFacebookIdToPost < ActiveRecord::Migration[4.2]
def change
add_column :posts, :facebook_id, :string
end
diff --git a/db/migrate/20130404211624_fix_default_image_url_from_profile.rb b/db/migrate/20130404211624_fix_default_image_url_from_profile.rb
index 4749728fc..80618b8a5 100644
--- a/db/migrate/20130404211624_fix_default_image_url_from_profile.rb
+++ b/db/migrate/20130404211624_fix_default_image_url_from_profile.rb
@@ -1,4 +1,4 @@
-class FixDefaultImageUrlFromProfile < ActiveRecord::Migration
+class FixDefaultImageUrlFromProfile < ActiveRecord::Migration[4.2]
def up
execute("UPDATE profiles SET image_url = REPLACE(image_url, 'images', 'assets'), image_url_small = REPLACE(image_url_small, 'images', 'assets'), image_url_medium = REPLACE(image_url_medium, 'images', 'assets') WHERE image_url LIKE '%images/user/default.png';")
end
diff --git a/db/migrate/20130429073928_add_tweet_id_to_post.rb b/db/migrate/20130429073928_add_tweet_id_to_post.rb
index f62c2b964..7f9c5808f 100644
--- a/db/migrate/20130429073928_add_tweet_id_to_post.rb
+++ b/db/migrate/20130429073928_add_tweet_id_to_post.rb
@@ -1,4 +1,4 @@
-class AddTweetIdToPost < ActiveRecord::Migration
+class AddTweetIdToPost < ActiveRecord::Migration[4.2]
def change
add_column :posts, :tweet_id, :string
add_index :posts, ['tweet_id'], :length => { "tweet_id" => 191 }
diff --git a/db/migrate/20130608171134_add_open_graph_cache.rb b/db/migrate/20130608171134_add_open_graph_cache.rb
index ccf4aecc4..ac4826c1f 100644
--- a/db/migrate/20130608171134_add_open_graph_cache.rb
+++ b/db/migrate/20130608171134_add_open_graph_cache.rb
@@ -1,4 +1,4 @@
-class AddOpenGraphCache < ActiveRecord::Migration
+class AddOpenGraphCache < ActiveRecord::Migration[4.2]
def up
create_table :open_graph_caches do |t|
t.string :title
diff --git a/db/migrate/20130613203350_remove_limit_from_root_guid_in_posts.rb b/db/migrate/20130613203350_remove_limit_from_root_guid_in_posts.rb
index 97b653a10..2e88f0a1e 100644
--- a/db/migrate/20130613203350_remove_limit_from_root_guid_in_posts.rb
+++ b/db/migrate/20130613203350_remove_limit_from_root_guid_in_posts.rb
@@ -1,4 +1,4 @@
-class RemoveLimitFromRootGuidInPosts < ActiveRecord::Migration
+class RemoveLimitFromRootGuidInPosts < ActiveRecord::Migration[4.2]
def up
remove_index 'posts', :name => 'index_posts_on_root_guid'
remove_index 'posts', :name => 'index_posts_on_author_id_and_root_guid'
diff --git a/db/migrate/20130717104359_migrate_activity_stream_to_status_message.rb b/db/migrate/20130717104359_migrate_activity_stream_to_status_message.rb
index c02282f81..c37d8dd3e 100644
--- a/db/migrate/20130717104359_migrate_activity_stream_to_status_message.rb
+++ b/db/migrate/20130717104359_migrate_activity_stream_to_status_message.rb
@@ -1,5 +1,5 @@
-class MigrateActivityStreamToStatusMessage < ActiveRecord::Migration
- class Post < ActiveRecord::Base; self.inheritance_column = false; end
+class MigrateActivityStreamToStatusMessage < ActiveRecord::Migration[4.2]
+ class Post < ApplicationRecord; self.inheritance_column = false; end
def up
posts_stream_photos = Post.where(type: 'ActivityStreams::Photo')
posts_stream_photos.each do |p|
diff --git a/db/migrate/20130801063213_add_tumblr_post_ids_to_posts.rb b/db/migrate/20130801063213_add_tumblr_post_ids_to_posts.rb
index e8ddb4877..638157388 100644
--- a/db/migrate/20130801063213_add_tumblr_post_ids_to_posts.rb
+++ b/db/migrate/20130801063213_add_tumblr_post_ids_to_posts.rb
@@ -1,4 +1,4 @@
-class AddTumblrPostIdsToPosts < ActiveRecord::Migration
+class AddTumblrPostIdsToPosts < ActiveRecord::Migration[4.2]
def change
add_column :posts, :tumblr_ids, :text
end
diff --git a/db/migrate/20131017093025_create_post_reports.rb b/db/migrate/20131017093025_create_post_reports.rb
index bb68ff896..5ccceca03 100644
--- a/db/migrate/20131017093025_create_post_reports.rb
+++ b/db/migrate/20131017093025_create_post_reports.rb
@@ -1,4 +1,4 @@
-class CreatePostReports < ActiveRecord::Migration
+class CreatePostReports < ActiveRecord::Migration[4.2]
def change
create_table :post_reports do |t|
t.integer :post_id, :null => false
diff --git a/db/migrate/20131213171804_create_simple_captcha_data.rb b/db/migrate/20131213171804_create_simple_captcha_data.rb
index 4573b2056..9068aec00 100644
--- a/db/migrate/20131213171804_create_simple_captcha_data.rb
+++ b/db/migrate/20131213171804_create_simple_captcha_data.rb
@@ -1,4 +1,4 @@
-class CreateSimpleCaptchaData < ActiveRecord::Migration
+class CreateSimpleCaptchaData < ActiveRecord::Migration[4.2]
def self.up
create_table :simple_captcha_data do |t|
t.string :key, :limit => 40
diff --git a/db/migrate/20140121132816_add_post_type_to_post_report.rb b/db/migrate/20140121132816_add_post_type_to_post_report.rb
index 4d6686eea..766efb9b9 100644
--- a/db/migrate/20140121132816_add_post_type_to_post_report.rb
+++ b/db/migrate/20140121132816_add_post_type_to_post_report.rb
@@ -1,4 +1,4 @@
-class AddPostTypeToPostReport < ActiveRecord::Migration
+class AddPostTypeToPostReport < ActiveRecord::Migration[4.2]
def change
add_column :post_reports, :post_type, :string, :null => false, :after => :post_id, :default => 'post'
change_column_default :post_reports, :post_type, nil
diff --git a/db/migrate/20140214104217_rename_post_report_to_report.rb b/db/migrate/20140214104217_rename_post_report_to_report.rb
index 2d477491e..3b02b0aec 100644
--- a/db/migrate/20140214104217_rename_post_report_to_report.rb
+++ b/db/migrate/20140214104217_rename_post_report_to_report.rb
@@ -1,4 +1,4 @@
-class RenamePostReportToReport < ActiveRecord::Migration
+class RenamePostReportToReport < ActiveRecord::Migration[4.2]
def self.up
rename_table :post_reports, :reports
end
diff --git a/db/migrate/20140222162826_devise_add_lastseenable_user.rb b/db/migrate/20140222162826_devise_add_lastseenable_user.rb
index 5c62814af..c0a5428d4 100644
--- a/db/migrate/20140222162826_devise_add_lastseenable_user.rb
+++ b/db/migrate/20140222162826_devise_add_lastseenable_user.rb
@@ -1,4 +1,4 @@
-class DeviseAddLastseenableUser < ActiveRecord::Migration
+class DeviseAddLastseenableUser < ActiveRecord::Migration[4.2]
def self.up
add_column :users, :last_seen, :datetime
User.find_each do |user|
diff --git a/db/migrate/20140308154022_create_polls.rb b/db/migrate/20140308154022_create_polls.rb
index f2d84ba6a..c9dd794a2 100644
--- a/db/migrate/20140308154022_create_polls.rb
+++ b/db/migrate/20140308154022_create_polls.rb
@@ -1,4 +1,4 @@
-class CreatePolls < ActiveRecord::Migration
+class CreatePolls < ActiveRecord::Migration[4.2]
def up
create_table :polls do |t|
t.string :question, :null => false
diff --git a/db/migrate/20140422134050_rename_post_columns_to_item.rb b/db/migrate/20140422134050_rename_post_columns_to_item.rb
index 4550eacd7..986326152 100644
--- a/db/migrate/20140422134050_rename_post_columns_to_item.rb
+++ b/db/migrate/20140422134050_rename_post_columns_to_item.rb
@@ -1,4 +1,4 @@
-class RenamePostColumnsToItem < ActiveRecord::Migration
+class RenamePostColumnsToItem < ActiveRecord::Migration[4.2]
def up
rename_column :reports, :post_id, :item_id
rename_column :reports, :post_type, :item_type
diff --git a/db/migrate/20140422134627_change_user_id_type_to_integer.rb b/db/migrate/20140422134627_change_user_id_type_to_integer.rb
index 1f4918e8b..019cef962 100644
--- a/db/migrate/20140422134627_change_user_id_type_to_integer.rb
+++ b/db/migrate/20140422134627_change_user_id_type_to_integer.rb
@@ -1,4 +1,4 @@
-class ChangeUserIdTypeToInteger < ActiveRecord::Migration
+class ChangeUserIdTypeToInteger < ActiveRecord::Migration[4.2]
def up
remove_column :reports, :user_id
add_column :reports, :user_id, :integer, :null => false, :default => 1
diff --git a/db/migrate/20140601102543_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20140601102543_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
index 8edb50807..5a3f71a25 100644
--- a/db/migrate/20140601102543_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
+++ b/db/migrate/20140601102543_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
@@ -1,5 +1,5 @@
# This migration comes from acts_as_taggable_on_engine (originally 3)
-class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
+class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]
def self.up
add_column :tags, :taggings_count, :integer, default: 0
diff --git a/db/migrate/20140801101230_create_chat_contacts.rb b/db/migrate/20140801101230_create_chat_contacts.rb
index 718b5ae8d..b50afcece 100644
--- a/db/migrate/20140801101230_create_chat_contacts.rb
+++ b/db/migrate/20140801101230_create_chat_contacts.rb
@@ -1,4 +1,4 @@
-class CreateChatContacts < ActiveRecord::Migration
+class CreateChatContacts < ActiveRecord::Migration[4.2]
def up
create_table :chat_contacts do |t|
t.integer :user_id, null: false
diff --git a/db/migrate/20140801101352_create_chat_fragments.rb b/db/migrate/20140801101352_create_chat_fragments.rb
index 0fbdc40ee..0457abf22 100644
--- a/db/migrate/20140801101352_create_chat_fragments.rb
+++ b/db/migrate/20140801101352_create_chat_fragments.rb
@@ -1,4 +1,4 @@
-class CreateChatFragments < ActiveRecord::Migration
+class CreateChatFragments < ActiveRecord::Migration[4.2]
def up
create_table :chat_fragments do |t|
t.integer :user_id, null: false
diff --git a/db/migrate/20140824230505_add_completed_at_to_account_deletions.rb b/db/migrate/20140824230505_add_completed_at_to_account_deletions.rb
index 9b2af8c6a..2c701dcac 100644
--- a/db/migrate/20140824230505_add_completed_at_to_account_deletions.rb
+++ b/db/migrate/20140824230505_add_completed_at_to_account_deletions.rb
@@ -1,4 +1,4 @@
-class AddCompletedAtToAccountDeletions < ActiveRecord::Migration
+class AddCompletedAtToAccountDeletions < ActiveRecord::Migration[4.2]
def change
add_column :account_deletions, :completed_at, :datetime
end
diff --git a/db/migrate/20140826165533_increase_simple_captcha_limit.rb b/db/migrate/20140826165533_increase_simple_captcha_limit.rb
index b4d43dd64..c0d7d4827 100644
--- a/db/migrate/20140826165533_increase_simple_captcha_limit.rb
+++ b/db/migrate/20140826165533_increase_simple_captcha_limit.rb
@@ -1,4 +1,4 @@
-class IncreaseSimpleCaptchaLimit < ActiveRecord::Migration
+class IncreaseSimpleCaptchaLimit < ActiveRecord::Migration[4.2]
def self.up
change_column :simple_captcha_data, :value, :string, :limit => 12
end
diff --git a/db/migrate/20140906192846_fix_open_graph_data.rb b/db/migrate/20140906192846_fix_open_graph_data.rb
index 54959931d..5aec2b531 100644
--- a/db/migrate/20140906192846_fix_open_graph_data.rb
+++ b/db/migrate/20140906192846_fix_open_graph_data.rb
@@ -1,4 +1,4 @@
-class FixOpenGraphData < ActiveRecord::Migration
+class FixOpenGraphData < ActiveRecord::Migration[4.2]
def self.up
change_column :open_graph_caches, :url, :text
change_column :open_graph_caches, :image, :text
diff --git a/db/migrate/20141001162851_add_remove_after_to_users.rb b/db/migrate/20141001162851_add_remove_after_to_users.rb
index c63b916b6..8169e5e8b 100644
--- a/db/migrate/20141001162851_add_remove_after_to_users.rb
+++ b/db/migrate/20141001162851_add_remove_after_to_users.rb
@@ -1,4 +1,4 @@
-class AddRemoveAfterToUsers < ActiveRecord::Migration
+class AddRemoveAfterToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :remove_after, :datetime
end
diff --git a/db/migrate/20141007003922_add_chat_enabled_to_aspects.rb b/db/migrate/20141007003922_add_chat_enabled_to_aspects.rb
index ba4fd31fc..a5e300b94 100644
--- a/db/migrate/20141007003922_add_chat_enabled_to_aspects.rb
+++ b/db/migrate/20141007003922_add_chat_enabled_to_aspects.rb
@@ -1,4 +1,4 @@
-class AddChatEnabledToAspects < ActiveRecord::Migration
+class AddChatEnabledToAspects < ActiveRecord::Migration[4.2]
def self.up
add_column :aspects, :chat_enabled, :boolean, default: false
end
diff --git a/db/migrate/20141024170120_create_chat_offline_messages.rb b/db/migrate/20141024170120_create_chat_offline_messages.rb
index 8c30101b0..5c31e632d 100644
--- a/db/migrate/20141024170120_create_chat_offline_messages.rb
+++ b/db/migrate/20141024170120_create_chat_offline_messages.rb
@@ -1,4 +1,4 @@
-class CreateChatOfflineMessages < ActiveRecord::Migration
+class CreateChatOfflineMessages < ActiveRecord::Migration[4.2]
def self.up
create_table :chat_offline_messages do |t|
t.string :from, :null => false
diff --git a/db/migrate/20141209041241_drop_open_graph_caches_with_invalid_urls.rb b/db/migrate/20141209041241_drop_open_graph_caches_with_invalid_urls.rb
index bfbfab884..1c2b3dbf7 100644
--- a/db/migrate/20141209041241_drop_open_graph_caches_with_invalid_urls.rb
+++ b/db/migrate/20141209041241_drop_open_graph_caches_with_invalid_urls.rb
@@ -1,4 +1,4 @@
-class DropOpenGraphCachesWithInvalidUrls < ActiveRecord::Migration
+class DropOpenGraphCachesWithInvalidUrls < ActiveRecord::Migration[4.2]
def up
OpenGraphCache.where(url: 'http://').delete_all
end
diff --git a/db/migrate/20141216213423_purge_orphan_conversations.rb b/db/migrate/20141216213423_purge_orphan_conversations.rb
index c5eb90bff..45e6f5856 100644
--- a/db/migrate/20141216213423_purge_orphan_conversations.rb
+++ b/db/migrate/20141216213423_purge_orphan_conversations.rb
@@ -1,4 +1,4 @@
-class PurgeOrphanConversations < ActiveRecord::Migration
+class PurgeOrphanConversations < ActiveRecord::Migration[4.2]
def up
Conversation.where(id: Conversation.joins("LEFT JOIN conversation_visibilities ON conversation_visibilities.conversation_id = conversations.id")
.group('conversations.id')
diff --git a/db/migrate/20141227120907_add_export_to_user.rb b/db/migrate/20141227120907_add_export_to_user.rb
index 376d5fe36..ef1779f76 100644
--- a/db/migrate/20141227120907_add_export_to_user.rb
+++ b/db/migrate/20141227120907_add_export_to_user.rb
@@ -1,4 +1,4 @@
-class AddExportToUser < ActiveRecord::Migration
+class AddExportToUser < ActiveRecord::Migration[4.2]
def change
add_column :users, :export, :string
add_column :users, :exported_at, :datetime
diff --git a/db/migrate/20141230214830_user_pref_strip_exif.rb b/db/migrate/20141230214830_user_pref_strip_exif.rb
index 79983181d..b573d4874 100644
--- a/db/migrate/20141230214830_user_pref_strip_exif.rb
+++ b/db/migrate/20141230214830_user_pref_strip_exif.rb
@@ -1,4 +1,4 @@
-class UserPrefStripExif < ActiveRecord::Migration
+class UserPrefStripExif < ActiveRecord::Migration[4.2]
def up
add_column :users, :strip_exif, :boolean, default: true
end
diff --git a/db/migrate/20150106050733_set_mysql_to_unicode_mb4.rb b/db/migrate/20150106050733_set_mysql_to_unicode_mb4.rb
deleted file mode 100644
index 37dd9373e..000000000
--- a/db/migrate/20150106050733_set_mysql_to_unicode_mb4.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-class SetMysqlToUnicodeMb4 < ActiveRecord::Migration
- # Converts the tables and strings columns to utf8mb4, which is the true, full
- # unicode support in MySQl
-
- def self.up
- # shorten indexes regardless of the RDBMS provider - for consitency
- shorten_indexes
- change_encoding('utf8mb4', 'utf8mb4_bin') if AppConfig.mysql?
- end
-
- def self.down
- change_encoding('utf8', 'utf8_bin') if AppConfig.mysql?
- end
-
- def check_config(encoding, collation)
- connection_config = ActiveRecord::Base.connection_config
- raise "Database encoding is not #{encoding}!" if connection_config[:encoding] != encoding
- raise "Database collation is not #{collation}!" if connection_config[:collation] != collation
- end
-
- def change_encoding(encoding, collation)
- # Make sure the podmin changed the database.yml file
- check_config(encoding, collation)
-
- execute "ALTER DATABASE `#{ActiveRecord::Base.connection.current_database}` CHARACTER SET #{encoding} COLLATE #{collation};"
-
- tables.each do |table|
-
- modify_text_columns = columns(table).select {|column| column.type == :text }.map {|column|
- "MODIFY `#{column.name}` TEXT #{'NOT' unless column.null } NULL#{" DEFAULT '#{column.default}'" if column.has_default?}"
- }.join(", ")
-
- execute "ALTER TABLE `#{table}` CONVERT TO CHARACTER SET #{encoding} COLLATE #{collation}#{", #{modify_text_columns}" unless modify_text_columns.empty?};"
- end
- end
-
- def shorten_indexes
- remove_index 'aspect_visibilities', :name => 'shareable_and_aspect_id'
- add_index 'aspect_visibilities', ["shareable_id", "shareable_type", "aspect_id"], :name => 'shareable_and_aspect_id', length: {"shareable_type"=>189}, :using => :btree
-
- remove_index 'aspect_visibilities', :name => 'index_aspect_visibilities_on_shareable_id_and_shareable_type'
- add_index 'aspect_visibilities', ["shareable_id", "shareable_type"], :name => 'index_aspect_visibilities_on_shareable_id_and_shareable_type', length: {"shareable_type"=>190}, :using => :btree
-
- remove_index 'chat_contacts', :name => 'index_chat_contacts_on_user_id_and_jid'
- add_index 'chat_contacts', ["user_id", "jid"], :name => 'index_chat_contacts_on_user_id_and_jid', length: {"jid"=>190}, :using => :btree, :unique => true
-
- remove_index 'comments', :name => 'index_comments_on_guid'
- add_index 'comments', ["guid"], :name => 'index_comments_on_guid', length: {"guid"=>191}, :using => :btree, :unique => true
-
- remove_index 'likes', :name => 'index_likes_on_guid'
- add_index 'likes', ["guid"], :name => 'index_likes_on_guid', length: {"guid"=>191}, :using => :btree, :unique => true
-
- remove_index 'o_embed_caches', :name => 'index_o_embed_caches_on_url'
- add_index 'o_embed_caches', ["url"], :name => 'index_o_embed_caches_on_url', length: {"url"=>191}, :using => :btree
-
- remove_index 'participations', :name => 'index_participations_on_guid'
- add_index 'participations', ["guid"], :name => 'index_participations_on_guid', length: {"guid"=>191}, :using => :btree
-
- remove_index 'people', :name => 'index_people_on_diaspora_handle'
- add_index "people", ["diaspora_handle"], :name => "index_people_on_diaspora_handle", :unique => true, :length => {"diaspora_handle" => 191}
-
- remove_index 'people', :name => 'index_people_on_guid'
- add_index 'people', ["guid"], :name => 'index_people_on_guid', length: {"guid"=>191}, :using => :btree, :unique => true
-
- remove_index 'photos', :name => 'index_photos_on_status_message_guid'
- add_index 'photos', ["status_message_guid"], :name => 'index_photos_on_status_message_guid', length: {"status_message_guid"=>191}, :using => :btree
-
- remove_index 'posts', :name => 'index_posts_on_guid'
- add_index 'posts', ["guid"], :name => 'index_posts_on_guid', length: {"guid"=>191}, :using => :btree, :unique => true
-
- remove_index 'posts', :name => 'index_posts_on_status_message_guid_and_pending'
- add_index 'posts', ["status_message_guid", "pending"], :name => 'index_posts_on_status_message_guid_and_pending', length: {"status_message_guid"=>190}, :using => :btree
-
- remove_index 'posts', :name => 'index_posts_on_status_message_guid'
- add_index 'posts', ["status_message_guid"], :name => 'index_posts_on_status_message_guid', length: {"status_message_guid"=>191}, :using => :btree
-
- remove_index 'posts', :name => 'index_posts_on_author_id_and_root_guid'
- add_index 'posts', ["author_id", "root_guid"], :name => 'index_posts_on_author_id_and_root_guid', length: {"root_guid"=>190}, :using => :btree, :unique => true
-
- remove_index 'posts', :name => 'index_posts_on_root_guid'
- add_index 'posts', ["root_guid"], :name => 'index_posts_on_root_guid', length: {"root_guid"=>191}
-
- remove_index 'posts', :name => 'index_posts_on_tweet_id'
- add_index 'posts', ['tweet_id'], :name => 'index_posts_on_tweet_id', length: {"tweet_id"=>191}, :using => :btree
-
- remove_index 'rails_admin_histories', :name => 'index_rails_admin_histories'
- add_index 'rails_admin_histories', ["item", "table", "month", "year"], :name => 'index_rails_admin_histories', length: {"table"=>188}, :using => :btree
-
- remove_index 'schema_migrations', :name => 'unique_schema_migrations'
- add_index 'schema_migrations', ["version"], :name => 'unique_schema_migrations', length: {"version"=>191}, :using => :btree
-
- remove_index 'services', :name => 'index_services_on_type_and_uid'
- add_index 'services', ["type", "uid"], :name => 'index_services_on_type_and_uid', length: {"type"=>64, "uid"=>127}, :using => :btree
-
- remove_index 'taggings', :name => 'index_taggings_on_taggable_id_and_taggable_type_and_context'
- add_index 'taggings', ["taggable_id", "taggable_type", "context"], :name => 'index_taggings_on_taggable_id_and_taggable_type_and_context', length: {"taggable_type"=>95, "context"=>95}, :using => :btree
-
- remove_index 'tags', :name => 'index_tags_on_name'
- add_index 'tags', ["name"], :name => 'index_tags_on_name', length: {"name"=>191}, :using => :btree, :unique => true
-
- remove_index 'users', :name => 'index_users_on_invitation_service_and_invitation_identifier'
- add_index 'users', ["invitation_service", "invitation_identifier"], :name => 'index_users_on_invitation_service_and_invitation_identifier', length: {"invitation_service"=>64, "invitation_identifier"=>127}, :using => :btree, :unique => true
-
- remove_index 'users', :name => 'index_users_on_username'
- add_index 'users', ["username"], :name => 'index_users_on_username', length: {"username"=>191}, :using => :btree, :unique => true
-
- remove_index 'users', :name => 'index_users_on_email'
- add_index 'users', ["email"], :name => 'index_users_on_email', length: {"email"=>191}, :using => :btree
-
- remove_index 'notifications', :name => 'index_notifications_on_target_type_and_target_id'
- add_index 'notifications', ["target_type", "target_id"], name: 'index_notifications_on_target_type_and_target_id', length: {"target_type"=>190}, using: :btree
- end
-end
diff --git a/db/migrate/20150209230946_disable_mail_for_closed_account.rb b/db/migrate/20150209230946_disable_mail_for_closed_account.rb
index 575b16cfc..2dd573745 100644
--- a/db/migrate/20150209230946_disable_mail_for_closed_account.rb
+++ b/db/migrate/20150209230946_disable_mail_for_closed_account.rb
@@ -1,4 +1,4 @@
-class DisableMailForClosedAccount < ActiveRecord::Migration
+class DisableMailForClosedAccount < ActiveRecord::Migration[4.2]
def up
User.joins(:person).where(people: {closed_account: true}).update_all(disable_mail: true)
end
diff --git a/db/migrate/20150220001357_add_photos_export_to_user.rb b/db/migrate/20150220001357_add_photos_export_to_user.rb
index f19349723..6bec80420 100644
--- a/db/migrate/20150220001357_add_photos_export_to_user.rb
+++ b/db/migrate/20150220001357_add_photos_export_to_user.rb
@@ -1,4 +1,4 @@
-class AddPhotosExportToUser < ActiveRecord::Migration
+class AddPhotosExportToUser < ActiveRecord::Migration[4.2]
def up
add_column :users, :exported_photos_file, :string
add_column :users, :exported_photos_at, :datetime
diff --git a/db/migrate/20150403192408_remove_deleted_aspects_from_auto_follow_back.rb b/db/migrate/20150403192408_remove_deleted_aspects_from_auto_follow_back.rb
index d0d12058d..f5f19e750 100644
--- a/db/migrate/20150403192408_remove_deleted_aspects_from_auto_follow_back.rb
+++ b/db/migrate/20150403192408_remove_deleted_aspects_from_auto_follow_back.rb
@@ -1,4 +1,4 @@
-class RemoveDeletedAspectsFromAutoFollowBack < ActiveRecord::Migration
+class RemoveDeletedAspectsFromAutoFollowBack < ActiveRecord::Migration[4.2]
def up
User.where.not(auto_follow_back_aspect_id: Aspect.select(:id))
.where(auto_follow_back: true)
diff --git a/db/migrate/20150403212139_fix_wrong_only_sharing.rb b/db/migrate/20150403212139_fix_wrong_only_sharing.rb
index 8299ea88b..c02f4bba6 100644
--- a/db/migrate/20150403212139_fix_wrong_only_sharing.rb
+++ b/db/migrate/20150403212139_fix_wrong_only_sharing.rb
@@ -1,4 +1,4 @@
-class FixWrongOnlySharing < ActiveRecord::Migration
+class FixWrongOnlySharing < ActiveRecord::Migration[4.2]
def up
Contact.where(sharing: true, receiving: false)
.where(id: AspectMembership.select(:contact_id))
diff --git a/db/migrate/20150523004437_enable_color_themes.rb b/db/migrate/20150523004437_enable_color_themes.rb
index d9cea868d..816fd1fbf 100644
--- a/db/migrate/20150523004437_enable_color_themes.rb
+++ b/db/migrate/20150523004437_enable_color_themes.rb
@@ -1,4 +1,4 @@
-class EnableColorThemes < ActiveRecord::Migration
+class EnableColorThemes < ActiveRecord::Migration[4.2]
def up
add_column(:users, :color_theme, :string)
end
diff --git a/db/migrate/20150531005120_cleanup_default_avatars.rb b/db/migrate/20150531005120_cleanup_default_avatars.rb
index 93010fb2a..f3dcee9a2 100644
--- a/db/migrate/20150531005120_cleanup_default_avatars.rb
+++ b/db/migrate/20150531005120_cleanup_default_avatars.rb
@@ -1,4 +1,4 @@
-class CleanupDefaultAvatars < ActiveRecord::Migration
+class CleanupDefaultAvatars < ActiveRecord::Migration[4.2]
def up
Profile.where("image_url LIKE ?", "%user/default%")
.update_all(image_url: nil, image_url_small: nil, image_url_medium: nil)
diff --git a/db/migrate/20150607143809_fix_photo_public_flag.rb b/db/migrate/20150607143809_fix_photo_public_flag.rb
index fa75167ef..ee223cd6a 100644
--- a/db/migrate/20150607143809_fix_photo_public_flag.rb
+++ b/db/migrate/20150607143809_fix_photo_public_flag.rb
@@ -1,4 +1,4 @@
-class FixPhotoPublicFlag < ActiveRecord::Migration
+class FixPhotoPublicFlag < ActiveRecord::Migration[4.2]
def up
Photo.joins(:status_message).where(posts: {public: true}).update_all(public: true)
end
diff --git a/db/migrate/20150613202109_create_o_auth_applications.rb b/db/migrate/20150613202109_create_o_auth_applications.rb
index 1170b5c9e..a39f0ace9 100644
--- a/db/migrate/20150613202109_create_o_auth_applications.rb
+++ b/db/migrate/20150613202109_create_o_auth_applications.rb
@@ -1,6 +1,6 @@
# Inspired by https://github.com/nov/openid_connect_sample/blob/master/db/migrate/20110829023826_create_clients.rb
-class CreateOAuthApplications < ActiveRecord::Migration
+class CreateOAuthApplications < ActiveRecord::Migration[4.2]
def change
create_table :o_auth_applications do |t|
t.belongs_to :user, index: true
diff --git a/db/migrate/20150630221004_add_public_to_profiles.rb b/db/migrate/20150630221004_add_public_to_profiles.rb
index 06973e027..4797c1f38 100644
--- a/db/migrate/20150630221004_add_public_to_profiles.rb
+++ b/db/migrate/20150630221004_add_public_to_profiles.rb
@@ -1,4 +1,4 @@
-class AddPublicToProfiles < ActiveRecord::Migration
+class AddPublicToProfiles < ActiveRecord::Migration[4.2]
def change
add_column :profiles, :public_details, :boolean, default: false
end
diff --git a/db/migrate/20150708153926_create_authorizations.rb b/db/migrate/20150708153926_create_authorizations.rb
index ee88ab017..b9e06dd2c 100644
--- a/db/migrate/20150708153926_create_authorizations.rb
+++ b/db/migrate/20150708153926_create_authorizations.rb
@@ -1,4 +1,4 @@
-class CreateAuthorizations < ActiveRecord::Migration
+class CreateAuthorizations < ActiveRecord::Migration[4.2]
def change
create_table :authorizations do |t|
t.belongs_to :user, index: true
diff --git a/db/migrate/20150708153928_create_o_auth_access_tokens.rb b/db/migrate/20150708153928_create_o_auth_access_tokens.rb
index d833011c5..779283cbe 100644
--- a/db/migrate/20150708153928_create_o_auth_access_tokens.rb
+++ b/db/migrate/20150708153928_create_o_auth_access_tokens.rb
@@ -1,6 +1,6 @@
# Inspired by https://github.com/nov/openid_connect_sample/blob/master/db/migrate/20110829023837_create_access_tokens.rb
-class CreateOAuthAccessTokens < ActiveRecord::Migration
+class CreateOAuthAccessTokens < ActiveRecord::Migration[4.2]
def change
create_table :o_auth_access_tokens do |t|
t.belongs_to :authorization, index: true
diff --git a/db/migrate/20150714055110_create_id_tokens.rb b/db/migrate/20150714055110_create_id_tokens.rb
index b1e3abdfa..df98206a4 100644
--- a/db/migrate/20150714055110_create_id_tokens.rb
+++ b/db/migrate/20150714055110_create_id_tokens.rb
@@ -1,6 +1,6 @@
# Inspired by https://github.com/nov/openid_connect_sample/blob/master/db/migrate/20110829024010_create_id_tokens.rb
-class CreateIdTokens < ActiveRecord::Migration
+class CreateIdTokens < ActiveRecord::Migration[4.2]
def change
create_table :id_tokens do |t|
t.belongs_to :authorization, index: true
diff --git a/db/migrate/20150724152052_remove_favorites_from_posts.rb b/db/migrate/20150724152052_remove_favorites_from_posts.rb
index 8d4bd873f..737d3c593 100644
--- a/db/migrate/20150724152052_remove_favorites_from_posts.rb
+++ b/db/migrate/20150724152052_remove_favorites_from_posts.rb
@@ -1,4 +1,4 @@
-class RemoveFavoritesFromPosts < ActiveRecord::Migration
+class RemoveFavoritesFromPosts < ActiveRecord::Migration[4.2]
def self.up
remove_column :posts, :favorite
end
diff --git a/db/migrate/20150731123113_create_pairwise_pseudonymous_identifiers.rb b/db/migrate/20150731123113_create_pairwise_pseudonymous_identifiers.rb
index 0c8690848..12ed8597f 100644
--- a/db/migrate/20150731123113_create_pairwise_pseudonymous_identifiers.rb
+++ b/db/migrate/20150731123113_create_pairwise_pseudonymous_identifiers.rb
@@ -1,6 +1,6 @@
# Inspired by https://github.com/nov/openid_connect_sample/blob/master/db/migrate/20110829024140_create_pairwise_pseudonymous_identifiers.rb
-class CreatePairwisePseudonymousIdentifiers < ActiveRecord::Migration
+class CreatePairwisePseudonymousIdentifiers < ActiveRecord::Migration[4.2]
def change
create_table :ppid do |t|
t.belongs_to :o_auth_application, index: true
diff --git a/db/migrate/20150731123114_add_status_to_pods.rb b/db/migrate/20150731123114_add_status_to_pods.rb
index b53051f06..e94a011b1 100644
--- a/db/migrate/20150731123114_add_status_to_pods.rb
+++ b/db/migrate/20150731123114_add_status_to_pods.rb
@@ -1,4 +1,4 @@
-class AddStatusToPods < ActiveRecord::Migration
+class AddStatusToPods < ActiveRecord::Migration[4.2]
def change
add_column :pods, :status, :integer, default: 0
add_column :pods, :checked_at, :datetime, default: Time.zone.at(0)
diff --git a/db/migrate/20150828132451_remove_duplicate_and_empty_pods.rb b/db/migrate/20150828132451_remove_duplicate_and_empty_pods.rb
index e93acf722..f3d434474 100644
--- a/db/migrate/20150828132451_remove_duplicate_and_empty_pods.rb
+++ b/db/migrate/20150828132451_remove_duplicate_and_empty_pods.rb
@@ -1,4 +1,4 @@
-class RemoveDuplicateAndEmptyPods < ActiveRecord::Migration
+class RemoveDuplicateAndEmptyPods < ActiveRecord::Migration[4.2]
def up
remove_dupes
remove_empty_or_nil
diff --git a/db/migrate/20151003142048_update_report_item_types.rb b/db/migrate/20151003142048_update_report_item_types.rb
index 9a318edff..3d4972537 100644
--- a/db/migrate/20151003142048_update_report_item_types.rb
+++ b/db/migrate/20151003142048_update_report_item_types.rb
@@ -1,4 +1,4 @@
-class UpdateReportItemTypes < ActiveRecord::Migration
+class UpdateReportItemTypes < ActiveRecord::Migration[4.2]
def change
Report.all.each do |report|
report.update_attribute :item_type, report[:item_type].capitalize
diff --git a/db/migrate/20151210213023_remove_signatures_from_relayables.rb b/db/migrate/20151210213023_remove_signatures_from_relayables.rb
index 1d2cb485c..c9b7a45fa 100644
--- a/db/migrate/20151210213023_remove_signatures_from_relayables.rb
+++ b/db/migrate/20151210213023_remove_signatures_from_relayables.rb
@@ -1,4 +1,4 @@
-class RemoveSignaturesFromRelayables < ActiveRecord::Migration
+class RemoveSignaturesFromRelayables < ActiveRecord::Migration[4.2]
def change
remove_column :comments, :parent_author_signature, :text
remove_column :poll_participations, :parent_author_signature, :text
diff --git a/db/migrate/20160124234712_extend_pods.rb b/db/migrate/20160124234712_extend_pods.rb
index 17fb6c215..9f2dc7ebc 100644
--- a/db/migrate/20160124234712_extend_pods.rb
+++ b/db/migrate/20160124234712_extend_pods.rb
@@ -1,5 +1,5 @@
-class ExtendPods < ActiveRecord::Migration
- class Pod < ActiveRecord::Base
+class ExtendPods < ActiveRecord::Migration[4.2]
+ class Pod < ApplicationRecord
has_many :people
DEFAULT_PORTS = [URI::HTTP::DEFAULT_PORT, URI::HTTPS::DEFAULT_PORT]
@@ -18,7 +18,7 @@ class ExtendPods < ActiveRecord::Migration
end
end
- class Person < ActiveRecord::Base
+ class Person < ApplicationRecord
belongs_to :owner, class_name: "User"
belongs_to :pod
@@ -27,7 +27,7 @@ class ExtendPods < ActiveRecord::Migration
end
end
- class User < ActiveRecord::Base
+ class User < ApplicationRecord
has_one :person, inverse_of: :owner, foreign_key: :owner_id
end
@@ -52,7 +52,7 @@ class ExtendPods < ActiveRecord::Migration
end
# cleanup unused pods
- Pod.joins("LEFT OUTER JOIN people ON pods.id = people.pod_id").delete_all("people.id is NULL")
+ Pod.joins("LEFT OUTER JOIN people ON pods.id = people.pod_id").where("people.id is NULL").delete_all
remove_column :people, :url
end
diff --git a/db/migrate/20160225232049_link_share_visibilities_with_user.rb b/db/migrate/20160225232049_link_share_visibilities_with_user.rb
index 3292b0503..8a6f0f5ea 100644
--- a/db/migrate/20160225232049_link_share_visibilities_with_user.rb
+++ b/db/migrate/20160225232049_link_share_visibilities_with_user.rb
@@ -1,5 +1,5 @@
-class LinkShareVisibilitiesWithUser < ActiveRecord::Migration
- class ShareVisibility < ActiveRecord::Base
+class LinkShareVisibilitiesWithUser < ActiveRecord::Migration[4.2]
+ class ShareVisibility < ApplicationRecord
end
def up
@@ -26,7 +26,7 @@ class LinkShareVisibilitiesWithUser < ActiveRecord::Migration
remove_column :share_visibilities, :contact_id
ShareVisibility.joins("LEFT OUTER JOIN users ON users.id = share_visibilities.user_id")
- .delete_all("users.id is NULL")
+ .where("users.id is NULL").delete_all
change_column :share_visibilities, :user_id, :integer, null: false
@@ -73,8 +73,8 @@ class LinkShareVisibilitiesWithUser < ActiveRecord::Migration
def cleanup_deleted_share_visibilities
ShareVisibility.joins("LEFT OUTER JOIN posts ON posts.id = share_visibilities.shareable_id")
- .where(shareable_type: "Post").delete_all("posts.id is NULL")
+ .where(shareable_type: "Post").where("posts.id is NULL").delete_all
ShareVisibility.joins("LEFT OUTER JOIN photos ON photos.id = share_visibilities.shareable_id")
- .where(shareable_type: "Photo").delete_all("photos.id is NULL")
+ .where(shareable_type: "Photo").where("photos.id is NULL").delete_all
end
end
diff --git a/db/migrate/20160302025129_cleanup_aspect_visibility.rb b/db/migrate/20160302025129_cleanup_aspect_visibility.rb
index c937ac4df..7d3ae9c5f 100644
--- a/db/migrate/20160302025129_cleanup_aspect_visibility.rb
+++ b/db/migrate/20160302025129_cleanup_aspect_visibility.rb
@@ -1,16 +1,16 @@
-class CleanupAspectVisibility < ActiveRecord::Migration
- class AspectVisibility < ActiveRecord::Base
+class CleanupAspectVisibility < ActiveRecord::Migration[4.2]
+ class AspectVisibility < ApplicationRecord
end
def up
AspectVisibility.joins("LEFT OUTER JOIN posts ON posts.id = aspect_visibilities.shareable_id")
- .where(shareable_type: "Post").delete_all("posts.id is NULL")
+ .where(shareable_type: "Post").where("posts.id is NULL").delete_all
AspectVisibility.joins("LEFT OUTER JOIN photos ON photos.id = aspect_visibilities.shareable_id")
- .where(shareable_type: "Photo").delete_all("photos.id is NULL")
+ .where(shareable_type: "Photo").where("photos.id is NULL").delete_all
AspectVisibility.joins("INNER JOIN posts ON posts.id = aspect_visibilities.shareable_id")
- .where(shareable_type: "Post").delete_all(posts: {public: true})
+ .where(shareable_type: "Post").where(posts: {public: true}).delete_all
AspectVisibility.joins("INNER JOIN photos ON photos.id = aspect_visibilities.shareable_id")
- .where(shareable_type: "Photo").delete_all(photos: {public: true})
+ .where(shareable_type: "Photo").where(photos: {public: true}).delete_all
remove_columns :aspect_visibilities, :created_at, :updated_at
end
diff --git a/db/migrate/20160307142216_cleanup_handles.rb b/db/migrate/20160307142216_cleanup_handles.rb
index b2ed8fc8a..e39be2279 100644
--- a/db/migrate/20160307142216_cleanup_handles.rb
+++ b/db/migrate/20160307142216_cleanup_handles.rb
@@ -1,4 +1,4 @@
-class CleanupHandles < ActiveRecord::Migration
+class CleanupHandles < ActiveRecord::Migration[4.2]
def change
remove_column :photos, :tmp_old_id, :integer
remove_column :photos, :diaspora_handle, :string
diff --git a/db/migrate/20160327103605_add_author_id_index_to_participations.rb b/db/migrate/20160327103605_add_author_id_index_to_participations.rb
index 8a6382aeb..c41607981 100644
--- a/db/migrate/20160327103605_add_author_id_index_to_participations.rb
+++ b/db/migrate/20160327103605_add_author_id_index_to_participations.rb
@@ -1,4 +1,4 @@
-class AddAuthorIdIndexToParticipations < ActiveRecord::Migration
+class AddAuthorIdIndexToParticipations < ActiveRecord::Migration[4.2]
def change
add_index :participations, :author_id, :using => :btree
end
diff --git a/db/migrate/20160509232726_cleanup_duplicates_and_add_unique_indexes.rb b/db/migrate/20160509232726_cleanup_duplicates_and_add_unique_indexes.rb
index 26b79067b..4e17deb71 100644
--- a/db/migrate/20160509232726_cleanup_duplicates_and_add_unique_indexes.rb
+++ b/db/migrate/20160509232726_cleanup_duplicates_and_add_unique_indexes.rb
@@ -1,4 +1,4 @@
-class CleanupDuplicatesAndAddUniqueIndexes < ActiveRecord::Migration
+class CleanupDuplicatesAndAddUniqueIndexes < ActiveRecord::Migration[4.2]
def up
# temporary index to speed up the migration
add_index :photos, :guid, length: 191
diff --git a/db/migrate/20160531170531_remove_duplicate_aspect_visibilities.rb b/db/migrate/20160531170531_remove_duplicate_aspect_visibilities.rb
index 8269606be..40306c898 100644
--- a/db/migrate/20160531170531_remove_duplicate_aspect_visibilities.rb
+++ b/db/migrate/20160531170531_remove_duplicate_aspect_visibilities.rb
@@ -1,4 +1,4 @@
-class RemoveDuplicateAspectVisibilities < ActiveRecord::Migration
+class RemoveDuplicateAspectVisibilities < ActiveRecord::Migration[4.2]
def up
where = "WHERE a1.aspect_id = a2.aspect_id AND a1.shareable_id = a2.shareable_id AND "\
"a1.shareable_type = a2.shareable_type AND a1.id > a2.id"
diff --git a/db/migrate/20160618033455_cleanup_participations.rb b/db/migrate/20160618033455_cleanup_participations.rb
index ffe857885..df27d04a7 100644
--- a/db/migrate/20160618033455_cleanup_participations.rb
+++ b/db/migrate/20160618033455_cleanup_participations.rb
@@ -1,5 +1,5 @@
-class CleanupParticipations < ActiveRecord::Migration
- class Participation < ActiveRecord::Base
+class CleanupParticipations < ActiveRecord::Migration[4.2]
+ class Participation < ApplicationRecord
end
def up
@@ -39,6 +39,6 @@ class CleanupParticipations < ActiveRecord::Migration
end
Participation.joins("LEFT OUTER JOIN posts ON posts.id = participations.target_id")
- .where(target_type: "Post").delete_all("posts.id is NULL")
+ .where(target_type: "Post").where("posts.id is NULL").delete_all
end
end
diff --git a/db/migrate/20160720212620_create_signature_tables.rb b/db/migrate/20160720212620_create_signature_tables.rb
index f9e2d6c05..fa843fcdd 100644
--- a/db/migrate/20160720212620_create_signature_tables.rb
+++ b/db/migrate/20160720212620_create_signature_tables.rb
@@ -1,5 +1,5 @@
-class CreateSignatureTables < ActiveRecord::Migration
- class SignatureOrder < ActiveRecord::Base
+class CreateSignatureTables < ActiveRecord::Migration[4.2]
+ class SignatureOrder < ApplicationRecord
end
RELAYABLES = %i(comment like poll_participation).freeze
diff --git a/db/migrate/20160802212635_cleanup_posts_table.rb b/db/migrate/20160802212635_cleanup_posts_table.rb
index 79e473e8e..ffab18c7d 100644
--- a/db/migrate/20160802212635_cleanup_posts_table.rb
+++ b/db/migrate/20160802212635_cleanup_posts_table.rb
@@ -1,4 +1,4 @@
-class CleanupPostsTable < ActiveRecord::Migration
+class CleanupPostsTable < ActiveRecord::Migration[4.2]
def change
remove_index :posts, column: %i(status_message_guid pending),
name: :index_posts_on_status_message_guid_and_pending, length: {status_message_guid: 190}
diff --git a/db/migrate/20160807212443_participation_counter.rb b/db/migrate/20160807212443_participation_counter.rb
index 871a1197f..719458ec7 100644
--- a/db/migrate/20160807212443_participation_counter.rb
+++ b/db/migrate/20160807212443_participation_counter.rb
@@ -1,18 +1,18 @@
-class ParticipationCounter < ActiveRecord::Migration
- class Comment < ActiveRecord::Base
+class ParticipationCounter < ActiveRecord::Migration[4.2]
+ class Comment < ApplicationRecord
end
- class Like < ActiveRecord::Base
+ class Like < ApplicationRecord
end
- class Participation < ActiveRecord::Base
+ class Participation < ApplicationRecord
belongs_to :author, class_name: "Person"
end
- class Poll < ActiveRecord::Base
+ class Poll < ApplicationRecord
end
- class PollParticipation < ActiveRecord::Base
+ class PollParticipation < ApplicationRecord
belongs_to :poll
end
diff --git a/db/migrate/20160810230114_cleanup_invitation_columns_from_users.rb b/db/migrate/20160810230114_cleanup_invitation_columns_from_users.rb
index f51312b2f..2022589fc 100644
--- a/db/migrate/20160810230114_cleanup_invitation_columns_from_users.rb
+++ b/db/migrate/20160810230114_cleanup_invitation_columns_from_users.rb
@@ -1,8 +1,8 @@
-class CleanupInvitationColumnsFromUsers < ActiveRecord::Migration
- class InvitationCode < ActiveRecord::Base
+class CleanupInvitationColumnsFromUsers < ActiveRecord::Migration[4.2]
+ class InvitationCode < ApplicationRecord
end
- class User < ActiveRecord::Base
+ class User < ApplicationRecord
end
def change
@@ -34,7 +34,7 @@ class CleanupInvitationColumnsFromUsers < ActiveRecord::Migration
InvitationCode.where("count < 0").update_all(count: new_counter)
# remove old invitation-users
- User.delete_all(username: nil)
+ User.where(username: nil).delete_all
change_column :users, :username, :string, null: false
end
@@ -47,7 +47,7 @@ class CleanupInvitationColumnsFromUsers < ActiveRecord::Migration
end
def create_invitations_table
- # rubocop:disable Style/ExtraSpacing
+ # rubocop:disable Layout/ExtraSpacing
create_table :invitations, force: :cascade do |t|
t.text :message, limit: 65_535
t.integer :sender_id, limit: 4
@@ -60,7 +60,7 @@ class CleanupInvitationColumnsFromUsers < ActiveRecord::Migration
t.boolean :admin, default: false
t.string :language, limit: 255, default: "en"
end
- # rubocop:enable Style/ExtraSpacing
+ # rubocop:enable Layout/ExtraSpacing
add_index :invitations, :aspect_id, name: :index_invitations_on_aspect_id, using: :btree
add_index :invitations, :recipient_id, name: :index_invitations_on_recipient_id, using: :btree
diff --git a/db/migrate/20160813115514_remove_id_tokens.rb b/db/migrate/20160813115514_remove_id_tokens.rb
index 36689d688..346b2a24b 100644
--- a/db/migrate/20160813115514_remove_id_tokens.rb
+++ b/db/migrate/20160813115514_remove_id_tokens.rb
@@ -1,6 +1,6 @@
require_relative "20150714055110_create_id_tokens"
-class RemoveIdTokens < ActiveRecord::Migration
+class RemoveIdTokens < ActiveRecord::Migration[4.2]
def change
revert CreateIdTokens
end
diff --git a/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb b/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb
index 70a62f68f..ddd1f5b3a 100644
--- a/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb
+++ b/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb
@@ -1,5 +1,5 @@
-class RemoveStartedSharingNotificationsWithoutContact < ActiveRecord::Migration
- class Notification < ActiveRecord::Base
+class RemoveStartedSharingNotificationsWithoutContact < ActiveRecord::Migration[4.2]
+ class Notification < ApplicationRecord
end
def up
@@ -7,6 +7,7 @@ class RemoveStartedSharingNotificationsWithoutContact < ActiveRecord::Migration
.joins("INNER JOIN people ON people.id = notifications.target_id")
.joins("LEFT OUTER JOIN contacts ON contacts.person_id = people.id " \
"AND contacts.user_id = notifications.recipient_id")
- .delete_all("contacts.id IS NULL")
+ .where("contacts.id IS NULL")
+ .delete_all
end
end
diff --git a/db/migrate/20160829170244_add_post_default_to_aspects.rb b/db/migrate/20160829170244_add_post_default_to_aspects.rb
index dcc2d76c6..e86193346 100644
--- a/db/migrate/20160829170244_add_post_default_to_aspects.rb
+++ b/db/migrate/20160829170244_add_post_default_to_aspects.rb
@@ -1,4 +1,4 @@
-class AddPostDefaultToAspects < ActiveRecord::Migration
+class AddPostDefaultToAspects < ActiveRecord::Migration[4.2]
def change
add_column :aspects, :post_default, :boolean, default: true
add_column :users, :post_default_public, :boolean, default: false
diff --git a/db/migrate/20160901072443_add_video_url_to_open_graph_cache.rb b/db/migrate/20160901072443_add_video_url_to_open_graph_cache.rb
index 487248a26..eb123a6b3 100644
--- a/db/migrate/20160901072443_add_video_url_to_open_graph_cache.rb
+++ b/db/migrate/20160901072443_add_video_url_to_open_graph_cache.rb
@@ -1,4 +1,4 @@
-class AddVideoUrlToOpenGraphCache < ActiveRecord::Migration
+class AddVideoUrlToOpenGraphCache < ActiveRecord::Migration[4.2]
def change
add_column :open_graph_caches, :video_url, :text
end
diff --git a/db/migrate/20160902180630_remove_invalid_unconfirmed_emails.rb b/db/migrate/20160902180630_remove_invalid_unconfirmed_emails.rb
index 086531c16..27a7feecf 100644
--- a/db/migrate/20160902180630_remove_invalid_unconfirmed_emails.rb
+++ b/db/migrate/20160902180630_remove_invalid_unconfirmed_emails.rb
@@ -1,5 +1,5 @@
-class RemoveInvalidUnconfirmedEmails < ActiveRecord::Migration
- class User < ActiveRecord::Base
+class RemoveInvalidUnconfirmedEmails < ActiveRecord::Migration[4.2]
+ class User < ApplicationRecord
end
def up
diff --git a/db/migrate/20160906225138_fix_photos_share_visibilities.rb b/db/migrate/20160906225138_fix_photos_share_visibilities.rb
index 3621fe28b..ff382a7d5 100644
--- a/db/migrate/20160906225138_fix_photos_share_visibilities.rb
+++ b/db/migrate/20160906225138_fix_photos_share_visibilities.rb
@@ -1,8 +1,8 @@
-class FixPhotosShareVisibilities < ActiveRecord::Migration
- class Photo < ActiveRecord::Base
+class FixPhotosShareVisibilities < ActiveRecord::Migration[4.2]
+ class Photo < ApplicationRecord
end
- class ShareVisibility < ActiveRecord::Base
+ class ShareVisibility < ApplicationRecord
end
def up
diff --git a/db/migrate/20161015174300_remove_empty_pod.rb b/db/migrate/20161015174300_remove_empty_pod.rb
index 482b4f5db..ba7369bc1 100644
--- a/db/migrate/20161015174300_remove_empty_pod.rb
+++ b/db/migrate/20161015174300_remove_empty_pod.rb
@@ -1,6 +1,6 @@
-class RemoveEmptyPod < ActiveRecord::Migration
+class RemoveEmptyPod < ActiveRecord::Migration[4.2]
def up
- Pod.delete_all("host IS NULL")
+ Pod.where("host IS NULL").delete_all
change_column :pods, :host, :string, null: false
end
diff --git a/db/migrate/20161024231443_add_scheduled_check_to_pod.rb b/db/migrate/20161024231443_add_scheduled_check_to_pod.rb
index 6d18ba228..b080564b7 100644
--- a/db/migrate/20161024231443_add_scheduled_check_to_pod.rb
+++ b/db/migrate/20161024231443_add_scheduled_check_to_pod.rb
@@ -1,4 +1,4 @@
-class AddScheduledCheckToPod < ActiveRecord::Migration
+class AddScheduledCheckToPod < ActiveRecord::Migration[4.2]
def change
add_column :pods, :scheduled_check, :boolean, default: false, null: false
end
diff --git a/db/migrate/20161107100840_polymorphic_mentions.rb b/db/migrate/20161107100840_polymorphic_mentions.rb
index 2f00e65fe..99f65d822 100644
--- a/db/migrate/20161107100840_polymorphic_mentions.rb
+++ b/db/migrate/20161107100840_polymorphic_mentions.rb
@@ -1,4 +1,4 @@
-class PolymorphicMentions < ActiveRecord::Migration
+class PolymorphicMentions < ActiveRecord::Migration[4.2]
def change
remove_index :mentions, column: %i(post_id)
remove_index :mentions, column: %i(person_id post_id), unique: true
@@ -17,10 +17,10 @@ class PolymorphicMentions < ActiveRecord::Migration
reversible(&method(:up_down))
end
- class Mention < ActiveRecord::Base
+ class Mention < ApplicationRecord
end
- class Notification < ActiveRecord::Base
+ class Notification < ApplicationRecord
end
def up_down(change)
diff --git a/db/migrate/20170430022507_remove_message_signature.rb b/db/migrate/20170430022507_remove_message_signature.rb
index f2519dba5..a8e65c2e0 100644
--- a/db/migrate/20170430022507_remove_message_signature.rb
+++ b/db/migrate/20170430022507_remove_message_signature.rb
@@ -1,4 +1,4 @@
-class RemoveMessageSignature < ActiveRecord::Migration
+class RemoveMessageSignature < ActiveRecord::Migration[4.2]
def change
remove_column :messages, :author_signature, :text
end
diff --git a/db/schema.rb b/db/schema.rb
deleted file mode 100644
index 48db06ecd..000000000
--- a/db/schema.rb
+++ /dev/null
@@ -1,675 +0,0 @@
-# encoding: UTF-8
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended that you check this file into your version control system.
-
-ActiveRecord::Schema.define(version: 20170430022507) do
-
- create_table "account_deletions", force: :cascade do |t|
- t.string "diaspora_handle", limit: 255
- t.integer "person_id", limit: 4
- t.datetime "completed_at"
- end
-
- create_table "aspect_memberships", force: :cascade do |t|
- t.integer "aspect_id", limit: 4, null: false
- t.integer "contact_id", limit: 4, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "aspect_memberships", ["aspect_id", "contact_id"], name: "index_aspect_memberships_on_aspect_id_and_contact_id", unique: true, using: :btree
- add_index "aspect_memberships", ["aspect_id"], name: "index_aspect_memberships_on_aspect_id", using: :btree
- add_index "aspect_memberships", ["contact_id"], name: "index_aspect_memberships_on_contact_id", using: :btree
-
- create_table "aspect_visibilities", force: :cascade do |t|
- t.integer "shareable_id", limit: 4, null: false
- t.integer "aspect_id", limit: 4, null: false
- t.string "shareable_type", limit: 255, default: "Post", null: false
- end
-
- add_index "aspect_visibilities", ["aspect_id"], name: "index_aspect_visibilities_on_aspect_id", using: :btree
- add_index "aspect_visibilities", ["shareable_id", "shareable_type", "aspect_id"], name: "shareable_and_aspect_id", length: {"shareable_id"=>nil, "shareable_type"=>189, "aspect_id"=>nil}, using: :btree
- add_index "aspect_visibilities", ["shareable_id", "shareable_type"], name: "index_aspect_visibilities_on_shareable_id_and_shareable_type", length: {"shareable_id"=>nil, "shareable_type"=>190}, using: :btree
-
- create_table "aspects", force: :cascade do |t|
- t.string "name", limit: 255, null: false
- t.integer "user_id", limit: 4, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.boolean "contacts_visible", default: true, null: false
- t.integer "order_id", limit: 4
- t.boolean "chat_enabled", default: false
- t.boolean "post_default", default: true
- end
-
- add_index "aspects", ["user_id", "contacts_visible"], name: "index_aspects_on_user_id_and_contacts_visible", using: :btree
- add_index "aspects", ["user_id"], name: "index_aspects_on_user_id", using: :btree
-
- create_table "authorizations", force: :cascade do |t|
- t.integer "user_id", limit: 4
- t.integer "o_auth_application_id", limit: 4
- t.string "refresh_token", limit: 255
- t.string "code", limit: 255
- t.string "redirect_uri", limit: 255
- t.string "nonce", limit: 255
- t.string "scopes", limit: 255
- t.boolean "code_used", default: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "authorizations", ["o_auth_application_id"], name: "index_authorizations_on_o_auth_application_id", using: :btree
- add_index "authorizations", ["user_id"], name: "index_authorizations_on_user_id", using: :btree
-
- create_table "blocks", force: :cascade do |t|
- t.integer "user_id", limit: 4
- t.integer "person_id", limit: 4
- end
-
- create_table "chat_contacts", force: :cascade do |t|
- t.integer "user_id", limit: 4, null: false
- t.string "jid", limit: 255, null: false
- t.string "name", limit: 255
- t.string "ask", limit: 128
- t.string "subscription", limit: 128, null: false
- end
-
- add_index "chat_contacts", ["user_id", "jid"], name: "index_chat_contacts_on_user_id_and_jid", unique: true, length: {"user_id"=>nil, "jid"=>190}, using: :btree
-
- create_table "chat_fragments", force: :cascade do |t|
- t.integer "user_id", limit: 4, null: false
- t.string "root", limit: 256, null: false
- t.string "namespace", limit: 256, null: false
- t.text "xml", limit: 65535, null: false
- end
-
- add_index "chat_fragments", ["user_id"], name: "index_chat_fragments_on_user_id", unique: true, using: :btree
-
- create_table "chat_offline_messages", force: :cascade do |t|
- t.string "from", limit: 255, null: false
- t.string "to", limit: 255, null: false
- t.text "message", limit: 65535, null: false
- t.datetime "created_at", null: false
- end
-
- create_table "comment_signatures", id: false, force: :cascade do |t|
- t.integer "comment_id", limit: 4, null: false
- t.text "author_signature", limit: 65535, null: false
- t.integer "signature_order_id", limit: 4, null: false
- t.text "additional_data", limit: 65535
- end
-
- add_index "comment_signatures", ["comment_id"], name: "index_comment_signatures_on_comment_id", unique: true, using: :btree
- add_index "comment_signatures", ["signature_order_id"], name: "comment_signatures_signature_orders_id_fk", using: :btree
-
- create_table "comments", force: :cascade do |t|
- t.text "text", limit: 65535, null: false
- t.integer "commentable_id", limit: 4, null: false
- t.integer "author_id", limit: 4, null: false
- t.string "guid", limit: 255, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.integer "likes_count", limit: 4, default: 0, null: false
- t.string "commentable_type", limit: 60, default: "Post", null: false
- end
-
- add_index "comments", ["author_id"], name: "index_comments_on_person_id", using: :btree
- add_index "comments", ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type", using: :btree
- add_index "comments", ["guid"], name: "index_comments_on_guid", unique: true, length: {"guid"=>191}, using: :btree
-
- create_table "contacts", force: :cascade do |t|
- t.integer "user_id", limit: 4, null: false
- t.integer "person_id", limit: 4, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.boolean "sharing", default: false, null: false
- t.boolean "receiving", default: false, null: false
- end
-
- add_index "contacts", ["person_id"], name: "index_contacts_on_person_id", using: :btree
- add_index "contacts", ["user_id", "person_id"], name: "index_contacts_on_user_id_and_person_id", unique: true, using: :btree
-
- create_table "conversation_visibilities", force: :cascade do |t|
- t.integer "conversation_id", limit: 4, null: false
- t.integer "person_id", limit: 4, null: false
- t.integer "unread", limit: 4, default: 0, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "conversation_visibilities", ["conversation_id", "person_id"], name: "index_conversation_visibilities_usefully", unique: true, using: :btree
- add_index "conversation_visibilities", ["conversation_id"], name: "index_conversation_visibilities_on_conversation_id", using: :btree
- add_index "conversation_visibilities", ["person_id"], name: "index_conversation_visibilities_on_person_id", using: :btree
-
- create_table "conversations", force: :cascade do |t|
- t.string "subject", limit: 255
- t.string "guid", limit: 255, null: false
- t.integer "author_id", limit: 4, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "conversations", ["author_id"], name: "conversations_author_id_fk", using: :btree
- add_index "conversations", ["guid"], name: "index_conversations_on_guid", unique: true, length: {"guid"=>191}, using: :btree
-
- create_table "invitation_codes", force: :cascade do |t|
- t.string "token", limit: 255
- t.integer "user_id", limit: 4
- t.integer "count", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- create_table "like_signatures", id: false, force: :cascade do |t|
- t.integer "like_id", limit: 4, null: false
- t.text "author_signature", limit: 65535, null: false
- t.integer "signature_order_id", limit: 4, null: false
- t.text "additional_data", limit: 65535
- end
-
- add_index "like_signatures", ["like_id"], name: "index_like_signatures_on_like_id", unique: true, using: :btree
- add_index "like_signatures", ["signature_order_id"], name: "like_signatures_signature_orders_id_fk", using: :btree
-
- create_table "likes", force: :cascade do |t|
- t.boolean "positive", default: true
- t.integer "target_id", limit: 4
- t.integer "author_id", limit: 4
- t.string "guid", limit: 255
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.string "target_type", limit: 60, null: false
- end
-
- add_index "likes", ["author_id"], name: "likes_author_id_fk", using: :btree
- add_index "likes", ["guid"], name: "index_likes_on_guid", unique: true, length: {"guid"=>191}, using: :btree
- add_index "likes", ["target_id", "author_id", "target_type"], name: "index_likes_on_target_id_and_author_id_and_target_type", unique: true, using: :btree
- add_index "likes", ["target_id"], name: "index_likes_on_post_id", using: :btree
-
- create_table "locations", force: :cascade do |t|
- t.string "address", limit: 255
- t.string "lat", limit: 255
- t.string "lng", limit: 255
- t.integer "status_message_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- create_table "mentions", force: :cascade do |t|
- t.integer "mentions_container_id", limit: 4, null: false
- t.integer "person_id", limit: 4, null: false
- t.string "mentions_container_type", limit: 255, null: false
- end
-
- add_index "mentions", ["mentions_container_id", "mentions_container_type"], name: "index_mentions_on_mc_id_and_mc_type", length: {"mentions_container_id"=>nil, "mentions_container_type"=>191}, using: :btree
- add_index "mentions", ["person_id", "mentions_container_id", "mentions_container_type"], name: "index_mentions_on_person_and_mc_id_and_mc_type", unique: true, length: {"person_id"=>nil, "mentions_container_id"=>nil, "mentions_container_type"=>191}, using: :btree
- add_index "mentions", ["person_id"], name: "index_mentions_on_person_id", using: :btree
-
- create_table "messages", force: :cascade do |t|
- t.integer "conversation_id", limit: 4, null: false
- t.integer "author_id", limit: 4, null: false
- t.string "guid", limit: 255, null: false
- t.text "text", limit: 65535, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "messages", ["author_id"], name: "index_messages_on_author_id", using: :btree
- add_index "messages", ["conversation_id"], name: "messages_conversation_id_fk", using: :btree
- add_index "messages", ["guid"], name: "index_messages_on_guid", unique: true, length: {"guid"=>191}, using: :btree
-
- create_table "notification_actors", force: :cascade do |t|
- t.integer "notification_id", limit: 4
- t.integer "person_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "notification_actors", ["notification_id", "person_id"], name: "index_notification_actors_on_notification_id_and_person_id", unique: true, using: :btree
- add_index "notification_actors", ["notification_id"], name: "index_notification_actors_on_notification_id", using: :btree
- add_index "notification_actors", ["person_id"], name: "index_notification_actors_on_person_id", using: :btree
-
- create_table "notifications", force: :cascade do |t|
- t.string "target_type", limit: 255
- t.integer "target_id", limit: 4
- t.integer "recipient_id", limit: 4, null: false
- t.boolean "unread", default: true, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.string "type", limit: 255
- end
-
- add_index "notifications", ["recipient_id"], name: "index_notifications_on_recipient_id", using: :btree
- add_index "notifications", ["target_id"], name: "index_notifications_on_target_id", using: :btree
- add_index "notifications", ["target_type", "target_id"], name: "index_notifications_on_target_type_and_target_id", length: {"target_type"=>190, "target_id"=>nil}, using: :btree
-
- create_table "o_auth_access_tokens", force: :cascade do |t|
- t.integer "authorization_id", limit: 4
- t.string "token", limit: 255
- t.datetime "expires_at"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "o_auth_access_tokens", ["authorization_id"], name: "index_o_auth_access_tokens_on_authorization_id", using: :btree
- add_index "o_auth_access_tokens", ["token"], name: "index_o_auth_access_tokens_on_token", unique: true, length: {"token"=>191}, using: :btree
-
- create_table "o_auth_applications", force: :cascade do |t|
- t.integer "user_id", limit: 4
- t.string "client_id", limit: 255
- t.string "client_secret", limit: 255
- t.string "client_name", limit: 255
- t.text "redirect_uris", limit: 65535
- t.string "response_types", limit: 255
- t.string "grant_types", limit: 255
- t.string "application_type", limit: 255, default: "web"
- t.string "contacts", limit: 255
- t.string "logo_uri", limit: 255
- t.string "client_uri", limit: 255
- t.string "policy_uri", limit: 255
- t.string "tos_uri", limit: 255
- t.string "sector_identifier_uri", limit: 255
- t.string "token_endpoint_auth_method", limit: 255
- t.text "jwks", limit: 65535
- t.string "jwks_uri", limit: 255
- t.boolean "ppid", default: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "o_auth_applications", ["client_id"], name: "index_o_auth_applications_on_client_id", unique: true, length: {"client_id"=>191}, using: :btree
- add_index "o_auth_applications", ["user_id"], name: "index_o_auth_applications_on_user_id", using: :btree
-
- create_table "o_embed_caches", force: :cascade do |t|
- t.string "url", limit: 1024, null: false
- t.text "data", limit: 65535, null: false
- end
-
- add_index "o_embed_caches", ["url"], name: "index_o_embed_caches_on_url", length: {"url"=>191}, using: :btree
-
- create_table "open_graph_caches", force: :cascade do |t|
- t.string "title", limit: 255
- t.string "ob_type", limit: 255
- t.text "image", limit: 65535
- t.text "url", limit: 65535
- t.text "description", limit: 65535
- t.text "video_url", limit: 65535
- end
-
- create_table "participations", force: :cascade do |t|
- t.string "guid", limit: 255
- t.integer "target_id", limit: 4
- t.string "target_type", limit: 60, null: false
- t.integer "author_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.integer "count", limit: 4, default: 1, null: false
- end
-
- add_index "participations", ["author_id"], name: "index_participations_on_author_id", using: :btree
- add_index "participations", ["guid"], name: "index_participations_on_guid", length: {"guid"=>191}, using: :btree
- add_index "participations", ["target_id", "target_type", "author_id"], name: "index_participations_on_target_id_and_target_type_and_author_id", unique: true, using: :btree
-
- create_table "people", force: :cascade do |t|
- t.string "guid", limit: 255, null: false
- t.string "diaspora_handle", limit: 255, null: false
- t.text "serialized_public_key", limit: 65535, null: false
- t.integer "owner_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.boolean "closed_account", default: false
- t.integer "fetch_status", limit: 4, default: 0
- t.integer "pod_id", limit: 4
- end
-
- add_index "people", ["diaspora_handle"], name: "index_people_on_diaspora_handle", unique: true, length: {"diaspora_handle"=>191}, using: :btree
- add_index "people", ["guid"], name: "index_people_on_guid", unique: true, length: {"guid"=>191}, using: :btree
- add_index "people", ["owner_id"], name: "index_people_on_owner_id", unique: true, using: :btree
- add_index "people", ["pod_id"], name: "people_pod_id_fk", using: :btree
-
- create_table "photos", force: :cascade do |t|
- t.integer "author_id", limit: 4, null: false
- t.boolean "public", default: false, null: false
- t.string "guid", limit: 255, null: false
- t.boolean "pending", default: false, null: false
- t.text "text", limit: 65535
- t.text "remote_photo_path", limit: 65535
- t.string "remote_photo_name", limit: 255
- t.string "random_string", limit: 255
- t.string "processed_image", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "unprocessed_image", limit: 255
- t.string "status_message_guid", limit: 255
- t.integer "comments_count", limit: 4
- t.integer "height", limit: 4
- t.integer "width", limit: 4
- end
-
- add_index "photos", ["guid"], name: "index_photos_on_guid", unique: true, length: {"guid"=>191}, using: :btree
- add_index "photos", ["status_message_guid"], name: "index_photos_on_status_message_guid", length: {"status_message_guid"=>191}, using: :btree
-
- create_table "pods", force: :cascade do |t|
- t.string "host", limit: 255, null: false
- t.boolean "ssl"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.integer "status", limit: 4, default: 0
- t.datetime "checked_at", default: '1970-01-01 00:00:00'
- t.datetime "offline_since"
- t.integer "response_time", limit: 4, default: -1
- t.string "software", limit: 255
- t.string "error", limit: 255
- t.integer "port", limit: 4
- t.boolean "blocked", default: false
- t.boolean "scheduled_check", default: false, null: false
- end
-
- add_index "pods", ["checked_at"], name: "index_pods_on_checked_at", using: :btree
- add_index "pods", ["host", "port"], name: "index_pods_on_host_and_port", unique: true, length: {"host"=>190, "port"=>nil}, using: :btree
- add_index "pods", ["offline_since"], name: "index_pods_on_offline_since", using: :btree
- add_index "pods", ["status"], name: "index_pods_on_status", using: :btree
-
- create_table "poll_answers", force: :cascade do |t|
- t.string "answer", limit: 255, null: false
- t.integer "poll_id", limit: 4, null: false
- t.string "guid", limit: 255
- t.integer "vote_count", limit: 4, default: 0
- end
-
- add_index "poll_answers", ["guid"], name: "index_poll_answers_on_guid", unique: true, length: {"guid"=>191}, using: :btree
- add_index "poll_answers", ["poll_id"], name: "index_poll_answers_on_poll_id", using: :btree
-
- create_table "poll_participation_signatures", id: false, force: :cascade do |t|
- t.integer "poll_participation_id", limit: 4, null: false
- t.text "author_signature", limit: 65535, null: false
- t.integer "signature_order_id", limit: 4, null: false
- t.text "additional_data", limit: 65535
- end
-
- add_index "poll_participation_signatures", ["poll_participation_id"], name: "index_poll_participation_signatures_on_poll_participation_id", unique: true, using: :btree
- add_index "poll_participation_signatures", ["signature_order_id"], name: "poll_participation_signatures_signature_orders_id_fk", using: :btree
-
- create_table "poll_participations", force: :cascade do |t|
- t.integer "poll_answer_id", limit: 4, null: false
- t.integer "author_id", limit: 4, null: false
- t.integer "poll_id", limit: 4, null: false
- t.string "guid", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "poll_participations", ["guid"], name: "index_poll_participations_on_guid", unique: true, length: {"guid"=>191}, using: :btree
- add_index "poll_participations", ["poll_id"], name: "index_poll_participations_on_poll_id", using: :btree
-
- create_table "polls", force: :cascade do |t|
- t.string "question", limit: 255, null: false
- t.integer "status_message_id", limit: 4, null: false
- t.boolean "status"
- t.string "guid", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "polls", ["guid"], name: "index_polls_on_guid", unique: true, length: {"guid"=>191}, using: :btree
- add_index "polls", ["status_message_id"], name: "index_polls_on_status_message_id", using: :btree
-
- create_table "posts", force: :cascade do |t|
- t.integer "author_id", limit: 4, null: false
- t.boolean "public", default: false, null: false
- t.string "guid", limit: 255, null: false
- t.string "type", limit: 40, null: false
- t.text "text", limit: 65535
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.string "provider_display_name", limit: 255
- t.string "root_guid", limit: 255
- t.integer "likes_count", limit: 4, default: 0
- t.integer "comments_count", limit: 4, default: 0
- t.integer "o_embed_cache_id", limit: 4
- t.integer "reshares_count", limit: 4, default: 0
- t.datetime "interacted_at"
- t.string "facebook_id", limit: 255
- t.string "tweet_id", limit: 255
- t.integer "open_graph_cache_id", limit: 4
- t.text "tumblr_ids", limit: 65535
- end
-
- add_index "posts", ["author_id", "root_guid"], name: "index_posts_on_author_id_and_root_guid", unique: true, length: {"author_id"=>nil, "root_guid"=>190}, using: :btree
- add_index "posts", ["author_id"], name: "index_posts_on_person_id", using: :btree
- add_index "posts", ["guid"], name: "index_posts_on_guid", unique: true, length: {"guid"=>191}, using: :btree
- add_index "posts", ["id", "type", "created_at"], name: "index_posts_on_id_and_type_and_created_at", using: :btree
- add_index "posts", ["id", "type"], name: "index_posts_on_id_and_type", using: :btree
- add_index "posts", ["root_guid"], name: "index_posts_on_root_guid", length: {"root_guid"=>191}, using: :btree
- add_index "posts", ["tweet_id"], name: "index_posts_on_tweet_id", length: {"tweet_id"=>191}, using: :btree
-
- create_table "ppid", force: :cascade do |t|
- t.integer "o_auth_application_id", limit: 4
- t.integer "user_id", limit: 4
- t.string "guid", limit: 32
- t.string "string", limit: 32
- t.string "identifier", limit: 255
- end
-
- add_index "ppid", ["o_auth_application_id"], name: "index_ppid_on_o_auth_application_id", using: :btree
- add_index "ppid", ["user_id"], name: "index_ppid_on_user_id", using: :btree
-
- create_table "profiles", force: :cascade do |t|
- t.string "diaspora_handle", limit: 255
- t.string "first_name", limit: 127
- t.string "last_name", limit: 127
- t.string "image_url", limit: 255
- t.string "image_url_small", limit: 255
- t.string "image_url_medium", limit: 255
- t.date "birthday"
- t.string "gender", limit: 255
- t.text "bio", limit: 65535
- t.boolean "searchable", default: true, null: false
- t.integer "person_id", limit: 4, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.string "location", limit: 255
- t.string "full_name", limit: 70
- t.boolean "nsfw", default: false
- t.boolean "public_details", default: false
- end
-
- add_index "profiles", ["full_name", "searchable"], name: "index_profiles_on_full_name_and_searchable", using: :btree
- add_index "profiles", ["full_name"], name: "index_profiles_on_full_name", using: :btree
- add_index "profiles", ["person_id"], name: "index_profiles_on_person_id", using: :btree
-
- create_table "rails_admin_histories", force: :cascade do |t|
- t.text "message", limit: 65535
- t.string "username", limit: 255
- t.integer "item", limit: 4
- t.string "table", limit: 255
- t.integer "month", limit: 2
- t.integer "year", limit: 8
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "rails_admin_histories", ["item", "table", "month", "year"], name: "index_rails_admin_histories", length: {"item"=>nil, "table"=>188, "month"=>nil, "year"=>nil}, using: :btree
-
- create_table "reports", force: :cascade do |t|
- t.integer "item_id", limit: 4, null: false
- t.string "item_type", limit: 255, null: false
- t.boolean "reviewed", default: false
- t.text "text", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "user_id", limit: 4, null: false
- end
-
- add_index "reports", ["item_id"], name: "index_reports_on_item_id", using: :btree
-
- create_table "roles", force: :cascade do |t|
- t.integer "person_id", limit: 4
- t.string "name", limit: 255
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- create_table "services", force: :cascade do |t|
- t.string "type", limit: 127, null: false
- t.integer "user_id", limit: 4, null: false
- t.string "uid", limit: 127
- t.string "access_token", limit: 255
- t.string "access_secret", limit: 255
- t.string "nickname", limit: 255
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "services", ["type", "uid"], name: "index_services_on_type_and_uid", length: {"type"=>64, "uid"=>nil}, using: :btree
- add_index "services", ["user_id"], name: "index_services_on_user_id", using: :btree
-
- create_table "share_visibilities", force: :cascade do |t|
- t.integer "shareable_id", limit: 4, null: false
- t.boolean "hidden", default: false, null: false
- t.string "shareable_type", limit: 60, default: "Post", null: false
- t.integer "user_id", limit: 4, null: false
- end
-
- add_index "share_visibilities", ["shareable_id", "shareable_type", "hidden", "user_id"], name: "shareable_and_hidden_and_user_id", using: :btree
- add_index "share_visibilities", ["shareable_id", "shareable_type", "user_id"], name: "shareable_and_user_id", unique: true, using: :btree
- add_index "share_visibilities", ["shareable_id"], name: "index_post_visibilities_on_post_id", using: :btree
- add_index "share_visibilities", ["user_id"], name: "index_share_visibilities_on_user_id", using: :btree
-
- create_table "signature_orders", force: :cascade do |t|
- t.string "order", limit: 255, null: false
- end
-
- add_index "signature_orders", ["order"], name: "index_signature_orders_on_order", unique: true, length: {"order"=>191}, using: :btree
-
- create_table "simple_captcha_data", force: :cascade do |t|
- t.string "key", limit: 40
- t.string "value", limit: 12
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "simple_captcha_data", ["key"], name: "idx_key", using: :btree
-
- create_table "tag_followings", force: :cascade do |t|
- t.integer "tag_id", limit: 4, null: false
- t.integer "user_id", limit: 4, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- add_index "tag_followings", ["tag_id", "user_id"], name: "index_tag_followings_on_tag_id_and_user_id", unique: true, using: :btree
- add_index "tag_followings", ["tag_id"], name: "index_tag_followings_on_tag_id", using: :btree
- add_index "tag_followings", ["user_id"], name: "index_tag_followings_on_user_id", using: :btree
-
- create_table "taggings", force: :cascade do |t|
- t.integer "tag_id", limit: 4
- t.integer "taggable_id", limit: 4
- t.string "taggable_type", limit: 127
- t.integer "tagger_id", limit: 4
- t.string "tagger_type", limit: 127
- t.string "context", limit: 127
- t.datetime "created_at"
- end
-
- add_index "taggings", ["created_at"], name: "index_taggings_on_created_at", using: :btree
- add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
- add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", length: {"taggable_id"=>nil, "taggable_type"=>95, "context"=>95}, using: :btree
- add_index "taggings", ["taggable_id", "taggable_type", "tag_id"], name: "index_taggings_uniquely", unique: true, using: :btree
-
- create_table "tags", force: :cascade do |t|
- t.string "name", limit: 255
- t.integer "taggings_count", limit: 4, default: 0
- end
-
- add_index "tags", ["name"], name: "index_tags_on_name", unique: true, length: {"name"=>191}, using: :btree
-
- create_table "user_preferences", force: :cascade do |t|
- t.string "email_type", limit: 255
- t.integer "user_id", limit: 4
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- create_table "users", force: :cascade do |t|
- t.string "username", limit: 255, null: false
- t.text "serialized_private_key", limit: 65535
- t.boolean "getting_started", default: true, null: false
- t.boolean "disable_mail", default: false, null: false
- t.string "language", limit: 255
- t.string "email", limit: 255, default: "", null: false
- t.string "encrypted_password", limit: 255, default: "", null: false
- t.string "reset_password_token", limit: 255
- t.datetime "remember_created_at"
- t.integer "sign_in_count", limit: 4, default: 0
- t.datetime "current_sign_in_at"
- t.datetime "last_sign_in_at"
- t.string "current_sign_in_ip", limit: 255
- t.string "last_sign_in_ip", limit: 255
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.integer "invited_by_id", limit: 4
- t.string "authentication_token", limit: 30
- t.string "unconfirmed_email", limit: 255
- t.string "confirm_email_token", limit: 30
- t.datetime "locked_at"
- t.boolean "show_community_spotlight_in_stream", default: true, null: false
- t.boolean "auto_follow_back", default: false
- t.integer "auto_follow_back_aspect_id", limit: 4
- t.text "hidden_shareables", limit: 65535
- t.datetime "reset_password_sent_at"
- t.datetime "last_seen"
- t.datetime "remove_after"
- t.string "export", limit: 255
- t.datetime "exported_at"
- t.boolean "exporting", default: false
- t.boolean "strip_exif", default: true
- t.string "exported_photos_file", limit: 255
- t.datetime "exported_photos_at"
- t.boolean "exporting_photos", default: false
- t.string "color_theme", limit: 255
- t.boolean "post_default_public", default: false
- end
-
- add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree
- add_index "users", ["email"], name: "index_users_on_email", unique: true, length: {"email"=>191}, using: :btree
- add_index "users", ["username"], name: "index_users_on_username", unique: true, length: {"username"=>191}, using: :btree
-
- add_foreign_key "aspect_memberships", "aspects", name: "aspect_memberships_aspect_id_fk", on_delete: :cascade
- add_foreign_key "aspect_memberships", "contacts", name: "aspect_memberships_contact_id_fk", on_delete: :cascade
- add_foreign_key "aspect_visibilities", "aspects", name: "aspect_visibilities_aspect_id_fk", on_delete: :cascade
- add_foreign_key "authorizations", "o_auth_applications"
- add_foreign_key "authorizations", "users"
- add_foreign_key "comment_signatures", "comments", name: "comment_signatures_comment_id_fk", on_delete: :cascade
- add_foreign_key "comment_signatures", "signature_orders", name: "comment_signatures_signature_orders_id_fk"
- add_foreign_key "comments", "people", column: "author_id", name: "comments_author_id_fk", on_delete: :cascade
- add_foreign_key "contacts", "people", name: "contacts_person_id_fk", on_delete: :cascade
- add_foreign_key "conversation_visibilities", "conversations", name: "conversation_visibilities_conversation_id_fk", on_delete: :cascade
- add_foreign_key "conversation_visibilities", "people", name: "conversation_visibilities_person_id_fk", on_delete: :cascade
- add_foreign_key "conversations", "people", column: "author_id", name: "conversations_author_id_fk", on_delete: :cascade
- add_foreign_key "like_signatures", "likes", name: "like_signatures_like_id_fk", on_delete: :cascade
- add_foreign_key "like_signatures", "signature_orders", name: "like_signatures_signature_orders_id_fk"
- add_foreign_key "likes", "people", column: "author_id", name: "likes_author_id_fk", on_delete: :cascade
- add_foreign_key "messages", "conversations", name: "messages_conversation_id_fk", on_delete: :cascade
- add_foreign_key "messages", "people", column: "author_id", name: "messages_author_id_fk", on_delete: :cascade
- add_foreign_key "notification_actors", "notifications", name: "notification_actors_notification_id_fk", on_delete: :cascade
- add_foreign_key "o_auth_access_tokens", "authorizations"
- add_foreign_key "o_auth_applications", "users"
- add_foreign_key "people", "pods", name: "people_pod_id_fk", on_delete: :cascade
- add_foreign_key "poll_participation_signatures", "poll_participations", name: "poll_participation_signatures_poll_participation_id_fk", on_delete: :cascade
- add_foreign_key "poll_participation_signatures", "signature_orders", name: "poll_participation_signatures_signature_orders_id_fk"
- add_foreign_key "posts", "people", column: "author_id", name: "posts_author_id_fk", on_delete: :cascade
- add_foreign_key "ppid", "o_auth_applications"
- add_foreign_key "ppid", "users"
- add_foreign_key "profiles", "people", name: "profiles_person_id_fk", on_delete: :cascade
- add_foreign_key "services", "users", name: "services_user_id_fk", on_delete: :cascade
- add_foreign_key "share_visibilities", "users", name: "share_visibilities_user_id_fk", on_delete: :cascade
-end
diff --git a/features/desktop/notifications.feature b/features/desktop/notifications.feature
index 13fc31a6b..7726d3d87 100644
--- a/features/desktop/notifications.feature
+++ b/features/desktop/notifications.feature
@@ -177,6 +177,5 @@ Feature: Notifications
When I wait for notifications to load
Then there should be 10 notifications loaded
When I scroll down on the notifications dropdown
- Then the notification dropdown should load more notifications
When I wait for notifications to load
Then there should be 15 notifications loaded
diff --git a/features/desktop/signs_up.feature b/features/desktop/signs_up.feature
index d68c58f19..bed865064 100644
--- a/features/desktop/signs_up.feature
+++ b/features/desktop/signs_up.feature
@@ -58,6 +58,7 @@ Feature: new user registration
| profile_first_name | some name |
And I fill in "tags" with "#rockstar"
And I press the first ".as-result-item" within "#as-results-tags"
+ And I wait until ajax requests finished
And I follow "awesome_button"
Then I should be on the stream page
And the publisher should be expanded
diff --git a/features/mobile/activity_stream.feature b/features/mobile/activity_stream.feature
index 27475abcd..823b4f7ad 100644
--- a/features/mobile/activity_stream.feature
+++ b/features/mobile/activity_stream.feature
@@ -21,7 +21,8 @@ Feature: Viewing my activity on the stream mobile page
Scenario: Show liked post on my activity
When I sign in as "bob@bob.bob" on the mobile website
When I click on selector "a.like-action.inactive"
- And I go to the activity stream page
+ Then I should see an element "a.like-action.active"
+ When I go to the activity stream page
Then I should see "My activity" within "#main"
And I should see "Hello! I am #newhere" within ".ltr"
diff --git a/features/step_definitions/notifications_steps.rb b/features/step_definitions/notifications_steps.rb
index 65aa57ad0..bd38c03f0 100644
--- a/features/step_definitions/notifications_steps.rb
+++ b/features/step_definitions/notifications_steps.rb
@@ -25,10 +25,6 @@ And "I scroll down on the notifications dropdown" do
page.execute_script("$('.notifications').scrollTop(350)")
end
-Then "the notification dropdown should load more notifications" do
- expect(find("#notification-dropdown")).to have_css(".loading")
-end
-
Then "the notification dropdown should be visible" do
expect(find(:css, "#notification-dropdown")).to be_visible
end
diff --git a/features/step_definitions/oidc_common_steps.rb b/features/step_definitions/oidc_common_steps.rb
index 24f543754..0f7ae95a8 100644
--- a/features/step_definitions/oidc_common_steps.rb
+++ b/features/step_definitions/oidc_common_steps.rb
@@ -1,5 +1,5 @@
Given /^a client with a provided picture exists for user "([^\"]*)"$/ do |email|
- app = FactoryGirl.create(:o_auth_application_with_image)
+ app = FactoryGirl.create(:o_auth_application, logo_uri: "/assets/user/default.png")
user = User.find_by(email: email)
FactoryGirl.create(:auth_with_read, user: user, o_auth_application: app)
end
diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb
index f2c564c8f..2ffdd4829 100644
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -93,6 +93,8 @@ When /^(?:|I )attach the file "([^"]*)" to (?:hidden )?"([^"]*)"(?: within "([^"
page.execute_script("$(\"input[name='#{field}']\").css('opacity', '1');")
attach_file(field, Rails.root.join(path).to_s)
end
+ # wait for the image to be ready
+ page.assert_selector(".loading", count: 0)
end
Then /^(?:|I )should see (\".+?\"[\s]*)(?:[\s]+within[\s]* "([^"]*)")?$/ do |vars, selector|
@@ -186,3 +188,9 @@ end
Then /^show me the page$/ do
save_and_open_page
end
+
+Then /^I wait until ajax requests finished$/ do
+ Timeout.timeout(Capybara.default_max_wait_time) do
+ loop until page.evaluate_script("jQuery.active") == 0
+ end
+end
diff --git a/features/support/env.rb b/features/support/env.rb
index 37b6afe95..cf95b37ef 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -52,7 +52,7 @@ Capybara.default_max_wait_time = 30
ActionController::Base.allow_rescue = false
Cucumber::Rails::Database.autorun_database_cleaner = true
-Cucumber::Rails::World.use_transactional_fixtures = false
+Cucumber::Rails::World.use_transactional_tests = false
require File.join(File.dirname(__FILE__), "integration_sessions_controller")
require File.join(File.dirname(__FILE__), "poor_mans_webmock")
diff --git a/features/support/publishing_cuke_helpers.rb b/features/support/publishing_cuke_helpers.rb
index d9a17b98c..a6e0593ff 100644
--- a/features/support/publishing_cuke_helpers.rb
+++ b/features/support/publishing_cuke_helpers.rb
@@ -95,7 +95,9 @@ module PublishingCukeHelpers
def like_stream_post(post_text)
within_post(post_text) do
- find(:css, 'a.like').click
+ action = find(:css, "a.like").text
+ find(:css, "a.like").click
+ expect(find(:css, "a.like")).not_to have_text(action)
end
end
diff --git a/lib/api/openid_connect/token_endpoint.rb b/lib/api/openid_connect/token_endpoint.rb
index a2e8c8ac2..7bde221a9 100644
--- a/lib/api/openid_connect/token_endpoint.rb
+++ b/lib/api/openid_connect/token_endpoint.rb
@@ -50,7 +50,7 @@ module Api
end
def app_valid?(o_auth_app, req)
- o_auth_app.client_secret == req.client_secret
+ o_auth_app.try(:client_secret) == req.client_secret
end
end
end
diff --git a/lib/diaspora/federation/entities.rb b/lib/diaspora/federation/entities.rb
index 48b07c43b..0165724fe 100644
--- a/lib/diaspora/federation/entities.rb
+++ b/lib/diaspora/federation/entities.rb
@@ -2,7 +2,7 @@ module Diaspora
module Federation
module Entities
def self.build(entity)
- public_send(Mappings.builder_for(entity.class), entity)
+ public_send(Mappings.builder_for(entity), entity)
end
def self.post(post)
diff --git a/lib/diaspora/federation/mappings.rb b/lib/diaspora/federation/mappings.rb
index 0d19af545..086df4685 100644
--- a/lib/diaspora/federation/mappings.rb
+++ b/lib/diaspora/federation/mappings.rb
@@ -1,82 +1,80 @@
module Diaspora
module Federation
module Mappings
+ # rubocop:disable Metrics/CyclomaticComplexity
+
# used in Diaspora::Federation::Receive
- def self.receiver_for(federation_class)
- fetch_from(ENTITY_RECEIVERS, federation_class)
+ def self.receiver_for(federation_entity)
+ case federation_entity
+ when DiasporaFederation::Entities::Comment then :comment
+ when DiasporaFederation::Entities::Contact then :contact
+ when DiasporaFederation::Entities::Conversation then :conversation
+ when DiasporaFederation::Entities::Like then :like
+ when DiasporaFederation::Entities::Message then :message
+ when DiasporaFederation::Entities::Participation then :participation
+ when DiasporaFederation::Entities::Photo then :photo
+ when DiasporaFederation::Entities::PollParticipation then :poll_participation
+ when DiasporaFederation::Entities::Profile then :profile
+ when DiasporaFederation::Entities::Reshare then :reshare
+ when DiasporaFederation::Entities::StatusMessage then :status_message
+ else not_found(federation_entity.class)
+ end
end
# used in Diaspora::Federation::Entities
- def self.builder_for(diaspora_class)
- fetch_from(ENTITY_BUILDERS, diaspora_class)
+ def self.builder_for(diaspora_entity)
+ case diaspora_entity
+ when AccountDeletion then :account_deletion
+ when Comment then :comment
+ when Contact then :contact
+ when Conversation then :conversation
+ when Like then :like
+ when Message then :message
+ when Participation then :participation
+ when Photo then :photo
+ when PollParticipation then :poll_participation
+ when Profile then :profile
+ when Reshare then :reshare
+ when Retraction then :retraction
+ when ContactRetraction then :retraction
+ when StatusMessage then :status_message
+ else not_found(diaspora_entity.class)
+ end
end
def self.model_class_for(entity_name)
- fetch_from(ENTITY_MODELS, entity_name)
+ case entity_name
+ when "Comment" then Comment
+ when "Conversation" then Conversation
+ when "Like" then Like
+ when "Participation" then Participation
+ when "PollParticipation" then PollParticipation
+ when "Photo" then Photo
+ when "Poll" then Poll
+ when "Post" then Post
+ when "Person" then Person # TODO: deprecated
+ when "Reshare" then Post
+ when "StatusMessage" then Post
+ else not_found(entity_name)
+ end
end
def self.entity_name_for(model)
- fetch_from(ENTITY_NAMES, model.class.base_class)
+ case model
+ when Comment then "Comment"
+ when Like then "Like"
+ when Participation then "Participation"
+ when PollParticipation then "PollParticipation"
+ when Photo then "Photo"
+ when Post then "Post"
+ else not_found(model.class)
+ end
end
+ # rubocop:enable Metrics/CyclomaticComplexity
- private_class_method def self.fetch_from(mapping, key)
- mapping.fetch(key) { raise DiasporaFederation::Entity::UnknownEntity, "unknown entity: #{key}" }
+ private_class_method def self.not_found(key)
+ raise DiasporaFederation::Entity::UnknownEntity, "unknown entity: #{key}"
end
-
- ENTITY_RECEIVERS = {
- DiasporaFederation::Entities::Comment => :comment,
- DiasporaFederation::Entities::Contact => :contact,
- DiasporaFederation::Entities::Conversation => :conversation,
- DiasporaFederation::Entities::Like => :like,
- DiasporaFederation::Entities::Message => :message,
- DiasporaFederation::Entities::Participation => :participation,
- DiasporaFederation::Entities::Photo => :photo,
- DiasporaFederation::Entities::PollParticipation => :poll_participation,
- DiasporaFederation::Entities::Profile => :profile,
- DiasporaFederation::Entities::Reshare => :reshare,
- DiasporaFederation::Entities::StatusMessage => :status_message
- }.freeze
-
- ENTITY_BUILDERS = {
- AccountDeletion => :account_deletion,
- Comment => :comment,
- Contact => :contact,
- Conversation => :conversation,
- Like => :like,
- Message => :message,
- Participation => :participation,
- Photo => :photo,
- PollParticipation => :poll_participation,
- Profile => :profile,
- Reshare => :reshare,
- Retraction => :retraction,
- ContactRetraction => :retraction,
- StatusMessage => :status_message
- }.freeze
-
- ENTITY_MODELS = {
- "Comment" => Comment,
- "Conversation" => Conversation,
- "Like" => Like,
- "Participation" => Participation,
- "PollParticipation" => PollParticipation,
- "Photo" => Photo,
- "Poll" => Poll,
- "Post" => Post,
- # TODO: deprecated
- "Person" => Person,
- "Reshare" => Post,
- "StatusMessage" => Post
- }.freeze
-
- ENTITY_NAMES = {
- Comment => "Comment",
- Like => "Like",
- Participation => "Participation",
- PollParticipation => "PollParticipation",
- Photo => "Photo",
- Post => "Post"
- }.freeze
end
end
end
diff --git a/lib/diaspora/federation/receive.rb b/lib/diaspora/federation/receive.rb
index 65e3dfa99..a3e8cadd4 100644
--- a/lib/diaspora/federation/receive.rb
+++ b/lib/diaspora/federation/receive.rb
@@ -4,7 +4,7 @@ module Diaspora
extend Diaspora::Logging
def self.perform(entity)
- public_send(Mappings.receiver_for(entity.class), entity)
+ public_send(Mappings.receiver_for(entity), entity)
end
def self.account_deletion(entity)
@@ -212,7 +212,8 @@ module Diaspora
poll.poll_answers = entity.poll_answers.map do |answer|
PollAnswer.new(
guid: answer.guid,
- answer: answer.answer
+ answer: answer.answer,
+ poll: poll
)
end
end
diff --git a/lib/diaspora/fetcher/public.rb b/lib/diaspora/fetcher/public.rb
index 34af2f30e..1a7fbd7ee 100644
--- a/lib/diaspora/fetcher/public.rb
+++ b/lib/diaspora/fetcher/public.rb
@@ -102,25 +102,16 @@ module Diaspora; module Fetcher; class Public
logger.debug "post: #{post.to_s[0..250]}"
- # disable some stuff we don't want for bulk inserts
- StatusMessage.skip_callback :create, :set_guid
-
entry = StatusMessage.diaspora_initialize(
- :author => @person,
- :public => true
- )
- entry.assign_attributes(
+ author: @person,
+ public: true,
guid: post["guid"],
text: post["text"],
provider_display_name: post["provider_display_name"],
created_at: ActiveSupport::TimeZone.new("UTC").parse(post["created_at"]).to_datetime,
- interacted_at: ActiveSupport::TimeZone.new("UTC").parse(post["interacted_at"]).to_datetime
)
entry.save
- # re-enable everything we disabled before
- StatusMessage.set_callback :create, :set_guid
-
end
set_fetch_status Public::Status_Processed
end
diff --git a/lib/diaspora/fields/target.rb b/lib/diaspora/fields/target.rb
index 1fbbf9796..7120c2a84 100644
--- a/lib/diaspora/fields/target.rb
+++ b/lib/diaspora/fields/target.rb
@@ -6,7 +6,6 @@ module Diaspora
belongs_to :target, polymorphic: true
validates :target_id, uniqueness: {scope: %i(target_type author_id)}
- validates :target, presence: true
end
end
end
diff --git a/lib/diaspora/relayable.rb b/lib/diaspora/relayable.rb
index f7c023291..5753674d4 100644
--- a/lib/diaspora/relayable.rb
+++ b/lib/diaspora/relayable.rb
@@ -6,6 +6,7 @@ module Diaspora
module Relayable
def self.included(model)
model.class_eval do
+ validates :parent, presence: true
validates_associated :parent
validate :author_is_not_ignored
diff --git a/lib/share_visibility_converter.rb b/lib/share_visibility_converter.rb
index c044570d3..82b9e2d23 100644
--- a/lib/share_visibility_converter.rb
+++ b/lib/share_visibility_converter.rb
@@ -1,24 +1,24 @@
#we dont have the environment, and it is not carring over from the migration
unless defined?(Person)
- class Person < ActiveRecord::Base
+ class Person < ApplicationRecord
belongs_to :owner, :class_name => 'User'
end
end
unless defined?(User)
- class User < ActiveRecord::Base
+ class User < ApplicationRecord
serialize :hidden_shareables, Hash
end
end
unless defined?(Contact)
- class Contact < ActiveRecord::Base
+ class Contact < ApplicationRecord
belongs_to :user
end
end
unless defined?(ShareVisibility)
- class ShareVisibility < ActiveRecord::Base
+ class ShareVisibility < ApplicationRecord
belongs_to :contact
end
end
@@ -28,14 +28,14 @@ class ShareVisibilityConverter
def self.copy_hidden_share_visibilities_to_users(only_recent = false)
query = ShareVisibility.where(:hidden => true).includes(:contact => :user)
query = query.where('share_visibilities.updated_at > ?', RECENT.weeks.ago) if only_recent
- count = query.count
+ count = query.count
puts "Updating #{count} records in batches of 1000..."
batch_count = 1
query.find_in_batches do |visibilities|
puts "Updating batch ##{batch_count} of #{(count/1000)+1}..."
batch_count += 1
- visibilities.each do |visibility|
+ visibilities.each do |visibility|
begin
type = visibility.shareable_type
id = visibility.shareable_id.to_s
diff --git a/lib/tasks/tests.rake b/lib/tasks/tests.rake
index 11c9bf3c5..b6e2bcfcf 100644
--- a/lib/tasks/tests.rake
+++ b/lib/tasks/tests.rake
@@ -1,14 +1,13 @@
namespace :ci do
namespace :travis do
- task prepare_db: %w(db:create db:test:load)
- task prepare: %w(prepare_db assets:generate_error_pages)
+ task prepare_db: %w[db:create db:migrate]
+ task prepare: %w[prepare_db assets:generate_error_pages]
desc "Run everyhting except cucumber"
- task other: %w(prepare tests:generate_fixtures spec jasmine:ci)
+ task other: %w[prepare tests:generate_fixtures spec jasmine:ci]
desc "Run cucumber"
- task cucumber: %w(prepare rake:cucumber)
-
+ task cucumber: %w[prepare rake:cucumber]
end
end
diff --git a/spec/controllers/admin/pods_controller_spec.rb b/spec/controllers/admin/pods_controller_spec.rb
index 9244351ee..784e29c6e 100644
--- a/spec/controllers/admin/pods_controller_spec.rb
+++ b/spec/controllers/admin/pods_controller_spec.rb
@@ -38,12 +38,12 @@ describe Admin::PodsController, type: :controller do
end
it "performs a connection test" do
- post :recheck, pod_id: 1
+ post :recheck, params: {pod_id: 1}
expect(response).to be_redirect
end
it "performs a connection test (format: json)" do
- post :recheck, pod_id: 1, format: :json
+ post :recheck, params: {pod_id: 1}, format: :json
expect(response.body).to eql(PodPresenter.new(@pod).to_json)
end
end
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index e96fa750e..7293ffab2 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -12,7 +12,7 @@ describe Admin::UsersController, :type => :controller do
expect(other_user).to receive(:close_account!)
allow(User).to receive(:find).and_return(other_user)
- post :close_account, id: other_user.id
+ post :close_account, params: {id: other_user.id}
end
end
diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb
index 4dfdd0ef5..e9580a5d2 100644
--- a/spec/controllers/admins_controller_spec.rb
+++ b/spec/controllers/admins_controller_spec.rb
@@ -70,12 +70,12 @@ describe AdminsController, :type => :controller do
end
it 'searches on username' do
- get :user_search, admins_controller_user_search: { username: @user.username }
+ get :user_search, params: {admins_controller_user_search: {username: @user.username}}
expect(assigns[:users]).to eq([@user])
end
it 'searches on email' do
- get :user_search, admins_controller_user_search: { email: @user.email }
+ get :user_search, params: {admins_controller_user_search: {email: @user.email}}
expect(assigns[:users]).to eq([@user])
end
@@ -88,7 +88,7 @@ describe AdminsController, :type => :controller do
o_13.profile.birthday = 20.years.ago.to_date
o_13.profile.save!
- get :user_search, admins_controller_user_search: { under13: '1' }
+ get :user_search, params: {admins_controller_user_search: {under13: "1"}}
expect(assigns[:users]).to include(u_13)
expect(assigns[:users]).not_to include(o_13)
@@ -110,20 +110,20 @@ describe AdminsController, :type => :controller do
end
it 'does not die if you do it twice' do
- get :admin_inviter, :identifier => 'bob@moms.com'
- get :admin_inviter, :identifier => 'bob@moms.com'
+ get :admin_inviter, params: {identifier: "bob@moms.com"}
+ get :admin_inviter, params: {identifier: "bob@moms.com"}
expect(response).to be_redirect
end
it 'invites a new user' do
expect(EmailInviter).to receive(:new).and_return(double.as_null_object)
- get :admin_inviter, :identifier => 'bob@moms.com'
+ get :admin_inviter, params: {identifier: "bob@moms.com"}
expect(response).to redirect_to user_search_path
expect(flash.notice).to include("invitation sent")
end
it "doesn't invite an existing user" do
- get :admin_inviter, identifier: bob.email
+ get :admin_inviter, params: {identifier: bob.email}
expect(response).to redirect_to user_search_path
expect(flash.notice).to include("error sending invite")
end
@@ -148,7 +148,7 @@ describe AdminsController, :type => :controller do
it "succeeds and renders stats for different ranges" do
%w(week 2weeks month).each do |range|
- get :stats, range: range
+ get :stats, params: {range: range}
expect(response).to be_success
expect(response).to render_template(:stats)
expect(response.body).not_to include(
diff --git a/spec/controllers/api/openid_connect/authorizations_controller_spec.rb b/spec/controllers/api/openid_connect/authorizations_controller_spec.rb
index f32ae0957..54435e0b3 100644
--- a/spec/controllers/api/openid_connect/authorizations_controller_spec.rb
+++ b/spec/controllers/api/openid_connect/authorizations_controller_spec.rb
@@ -1,7 +1,5 @@
describe Api::OpenidConnect::AuthorizationsController, type: :request do
let!(:client) { FactoryGirl.create(:o_auth_application) }
- let!(:client_with_xss) { FactoryGirl.create(:o_auth_application_with_xss) }
- let!(:client_with_multiple_redirects) { FactoryGirl.create(:o_auth_application_with_multiple_redirects) }
before do
sign_in alice, scope: :user
@@ -12,19 +10,19 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when valid parameters are passed" do
context "as GET request" do
it "should return a form page" do
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)
+ scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)}
expect(response.body).to match("Diaspora Test Client")
end
end
context "using claims" do
it "should return a form page" do
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
scope: "openid", claims: "{\"userinfo\": {\"name\": {\"essential\": true}}}",
- nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)
+ nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)}
expect(response.body).to match("Diaspora Test Client")
end
end
@@ -37,9 +35,9 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
claims: {userinfo: {name: {essential: true}}}}
payload = JWT.encoded_payload(JSON.parse(payload_hash.to_json))
request_object = header + "." + payload + "."
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "openid", nonce: "hello", state: "hello", request: request_object
+ scope: "openid", nonce: "hello", state: "hello", request: request_object}
expect(response.body).to match("Diaspora Test Client")
end
end
@@ -51,18 +49,18 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
response_type: "id_token", scope: "openid", nonce: "hello", state: "hello"}
payload = JWT.encoded_payload(JSON.parse(payload_hash.to_json))
request_object = header + "." + payload + "."
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "openid", nonce: "hello", state: "hello", request: request_object
+ scope: "openid", nonce: "hello", state: "hello", request: request_object}
expect(response.body).to match("Diaspora Test Client")
end
end
context "as POST request" do
it "should return a form page" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)
+ scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)}
expect(response.body).to match("Diaspora Test Client")
end
end
@@ -70,9 +68,8 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when client id is missing" do
it "should return an bad request error" do
- post api_openid_connect_authorizations_new_path,
- redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)
+ post api_openid_connect_authorizations_new_path, params: {redirect_uri: "http://localhost:3000/",
+ response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)}
expect(response.body).to include("The request was malformed")
end
end
@@ -84,8 +81,8 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
# When client has only one redirect uri registered, only that redirect uri can be used. Hence,
# we should implicitly assume the client wants to use that registered URI.
# See https://github.com/nov/rack-oauth2/blob/master/lib/rack/oauth2/server/authorize.rb#L63
- post api_openid_connect_authorizations_new_path, client_id: client.client_id, response_type: "id_token",
- scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
+ response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)}
expect(response.body).to match("Diaspora Test Client")
end
end
@@ -93,45 +90,46 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when multiple redirect URLs are pre-registered" do
it "should return an invalid request error" do
- post api_openid_connect_authorizations_new_path, client_id: client_with_multiple_redirects.client_id,
- response_type: "id_token",
- scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)
+ client_with_multiple_redirects =
+ FactoryGirl.create(:o_auth_application, redirect_uris: %w[http://localhost:3000/ http://localhost/])
+ post api_openid_connect_authorizations_new_path, params: {client_id: client_with_multiple_redirects.client_id,
+ response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)}
expect(response.body).to include("The request was malformed")
end
end
context "when redirect URI does not match pre-registered URIs" do
it "should return an invalid request error" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:2000/",
- response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16)
+ response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16)}
expect(response.body).to include("Invalid client id or redirect uri")
end
end
context "when an unsupported scope is passed in" do
it "should return an invalid scope error" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "random", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)
+ scope: "random", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)}
expect(response.body).to match("error=invalid_scope")
end
end
context "when nonce is missing" do
it "should return an invalid request error" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/",
- response_type: "id_token", scope: "openid", state: SecureRandom.hex(16)
+ response_type: "id_token", scope: "openid", state: SecureRandom.hex(16)}
expect(response.location).to match("error=invalid_request")
end
end
context "when prompt is none" do
it "should return an interaction required error" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/",
- response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none"
+ response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none"}
expect(response.body).to include("User must already be authorized when `prompt` is `none`")
end
end
@@ -142,27 +140,27 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
end
it "should return an interaction required error" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/",
- response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none"
+ response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none"}
expect(response.body).to include("User must already be logged in when `prompt` is `none`")
end
end
context "when prompt is none and consent" do
it "should return an interaction required error" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/",
- response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none consent"
+ response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none consent"}
expect(response.location).to match("error=invalid_request")
end
end
context "when prompt is select_account" do
it "should return an account_selection_required error" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/",
- response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "select_account"
+ response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "select_account"}
expect(response.location).to match("error=account_selection_required")
expect(response.location).to match("state=1234")
end
@@ -170,26 +168,28 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when prompt is none and client ID is invalid" do
it "should return an account_selection_required error" do
- post api_openid_connect_authorizations_new_path, client_id: "random", redirect_uri: "http://localhost:3000/",
- response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none"
+ post api_openid_connect_authorizations_new_path, params: {client_id: "random",
+ redirect_uri: "http://localhost:3000/", response_type: "id_token", scope: "openid", state: 1234,
+ display: "page", prompt: "none"}
expect(response.body).to include("Invalid client id or redirect uri")
end
end
context "when prompt is none and redirect URI does not match pre-registered URIs" do
it "should return an account_selection_required error" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://randomuri:3000/",
- response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none"
+ response_type: "id_token", scope: "openid", state: 1234, display: "page", prompt: "none"}
expect(response.body).to include("Invalid client id or redirect uri")
end
end
context "when XSS script is passed as name" do
it "should escape html" do
- post api_openid_connect_authorizations_new_path, client_id: client_with_xss.client_id,
+ client_with_xss = FactoryGirl.create(:o_auth_application_with_xss)
+ post api_openid_connect_authorizations_new_path, params: {client_id: client_with_xss.client_id,
redirect_uri: "http://localhost:3000/",
- response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)
+ response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)}
expect(response.body).to_not include("")
end
end
@@ -203,9 +203,9 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when valid parameters are passed" do
before do
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "openid", nonce: 413_093_098_3, state: 413_093_098_3
+ scope: "openid", nonce: 413_093_098_3, state: 413_093_098_3}
end
it "should return the id token in a fragment" do
@@ -224,10 +224,10 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when prompt is none" do
it "should return the id token in a fragment" do
- post api_openid_connect_authorizations_new_path, client_id: client.client_id,
+ post api_openid_connect_authorizations_new_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/",
response_type: "id_token", scope: "openid", nonce: 413_093_098_3, state: 413_093_098_3,
- display: "page", prompt: "none"
+ display: "page", prompt: "none"}
expect(response.location).to include("id_token=")
encoded_id_token = response.location[/(?<=id_token=)[^&]+/]
decoded_token = OpenIDConnect::ResponseObject::IdToken.decode encoded_id_token,
@@ -239,19 +239,19 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when prompt contains consent" do
it "should return a consent form page" do
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/",
response_type: "id_token", scope: "openid", nonce: 413_093_098_3, state: 413_093_098_3,
- display: "page", prompt: "consent"
+ display: "page", prompt: "consent"}
expect(response.body).to match("Diaspora Test Client")
end
end
context "when scopes are escalated" do
before do
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "openid read", nonce: 413_093_098_3, state: 413_093_098_3
+ scope: "openid read", nonce: 413_093_098_3, state: 413_093_098_3}
end
it "should receive another authorization request" do
@@ -259,7 +259,7 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
end
it "should overwrite old authorization scope after approval" do
- post api_openid_connect_authorizations_path, approve: "true"
+ post api_openid_connect_authorizations_path, params: {approve: "true"}
authorization_with_old_scope =
Api::OpenidConnect::Authorization.find_by_client_id_user_and_scopes(client.client_id, alice, ["openid"])
expect(authorization_with_old_scope).to be_nil
@@ -271,14 +271,14 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
describe "#create" do
context "when id_token token" do
before do
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token token",
- scope: "openid", nonce: 418_093_098_3, state: 418_093_098_3
+ scope: "openid", nonce: 418_093_098_3, state: 418_093_098_3}
end
context "when authorization is approved" do
before do
- post api_openid_connect_authorizations_path, approve: "true"
+ post api_openid_connect_authorizations_path, params: {approve: "true"}
end
it "should return the id token in a fragment" do
@@ -302,14 +302,14 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when id_token" do
before do
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "id_token",
- scope: "openid", nonce: 418_093_098_3, state: 418_093_098_3
+ scope: "openid", nonce: 418_093_098_3, state: 418_093_098_3}
end
context "when authorization is approved" do
before do
- post api_openid_connect_authorizations_path, approve: "true"
+ post api_openid_connect_authorizations_path, params: {approve: "true"}
end
it "should return the id token in a fragment" do
@@ -328,7 +328,7 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when authorization is denied" do
before do
- post api_openid_connect_authorizations_path, approve: "false"
+ post api_openid_connect_authorizations_path, params: {approve: "false"}
end
it "should return an error in the fragment" do
@@ -343,14 +343,14 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when code" do
before do
- get new_api_openid_connect_authorization_path, client_id: client.client_id,
+ get new_api_openid_connect_authorization_path, params: {client_id: client.client_id,
redirect_uri: "http://localhost:3000/", response_type: "code",
- scope: "openid", nonce: 418_093_098_3, state: 418_093_098_3
+ scope: "openid", nonce: 418_093_098_3, state: 418_093_098_3}
end
context "when authorization is approved" do
before do
- post api_openid_connect_authorizations_path, approve: "true"
+ post api_openid_connect_authorizations_path, params: {approve: "true"}
end
it "should return the code" do
@@ -364,7 +364,7 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
context "when authorization is denied" do
before do
- post api_openid_connect_authorizations_path, approve: "false"
+ post api_openid_connect_authorizations_path, params: {approve: "false"}
end
it "should return an error" do
@@ -379,14 +379,10 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do
end
describe "#destroy" do
- let!(:auth_with_read) { FactoryGirl.create(:auth_with_read) }
-
context "with existent authorization" do
- before do
- delete api_openid_connect_authorization_path(auth_with_read.id)
- end
-
it "removes the authorization" do
+ auth_with_read = FactoryGirl.create(:auth_with_read, o_auth_application: client)
+ delete api_openid_connect_authorization_path(auth_with_read.id)
expect(Api::OpenidConnect::Authorization.find_by(id: auth_with_read.id)).to be_nil
end
end
diff --git a/spec/controllers/api/openid_connect/clients_controller_spec.rb b/spec/controllers/api/openid_connect/clients_controller_spec.rb
index a12ad43b8..33776fdfb 100644
--- a/spec/controllers/api/openid_connect/clients_controller_spec.rb
+++ b/spec/controllers/api/openid_connect/clients_controller_spec.rb
@@ -9,11 +9,11 @@ describe Api::OpenidConnect::ClientsController, type: :controller, suppress_csrf
"User-Agent" => "Faraday v0.11.0"
})
.to_return(status: 200, body: "[\"http://localhost\"]", headers: {})
- post :create, redirect_uris: ["http://localhost"], client_name: "diaspora client",
+ post :create, params: {redirect_uris: ["http://localhost"], client_name: "diaspora client",
response_types: [], grant_types: [], application_type: "web", contacts: [],
logo_uri: "http://example.com/logo.png", client_uri: "http://example.com/client",
policy_uri: "http://example.com/policy", tos_uri: "http://example.com/tos",
- sector_identifier_uri: "http://example.com/uris", subject_type: "pairwise"
+ sector_identifier_uri: "http://example.com/uris", subject_type: "pairwise"}
client_json = JSON.parse(response.body)
expect(client_json["client_id"].length).to eq(32)
expect(client_json["ppid"]).to eq(true)
@@ -29,7 +29,7 @@ describe Api::OpenidConnect::ClientsController, type: :controller, suppress_csrf
"User-Agent" => "Faraday v0.11.0"
})
.to_return(status: 200, body: "[\"http://localhost\"]", headers: {})
- post :create, redirect_uris: ["http://localhost"], client_name: "diaspora client",
+ post :create, params: {redirect_uris: ["http://localhost"], client_name: "diaspora client",
response_types: [], grant_types: [], application_type: "web", contacts: [],
logo_uri: "http://example.com/logo.png", client_uri: "http://example.com/client",
policy_uri: "http://example.com/policy", tos_uri: "http://example.com/tos",
@@ -74,7 +74,7 @@ describe Api::OpenidConnect::ClientsController, type: :controller, suppress_csrf
kid: "a3"
}
]
- }
+ }}
client_json = JSON.parse(response.body)
expect(client_json["client_id"].length).to eq(32)
expect(client_json["ppid"]).to eq(true)
@@ -98,13 +98,13 @@ describe Api::OpenidConnect::ClientsController, type: :controller, suppress_csrf
})
.to_return(status: 200,
body: "{\"keys\":[{\"kty\":\"RSA\",\"e\":\"AQAB\",\"n\":\"qpW\",\"use\":\"sig\"}]}", headers: {})
- post :create, redirect_uris: ["http://localhost"], client_name: "diaspora client",
+ post :create, params: {redirect_uris: ["http://localhost"], client_name: "diaspora client",
response_types: [], grant_types: [], application_type: "web", contacts: [],
logo_uri: "http://example.com/logo.png", client_uri: "http://example.com/client",
policy_uri: "http://example.com/policy", tos_uri: "http://example.com/tos",
sector_identifier_uri: "http://example.com/uris", subject_type: "pairwise",
token_endpoint_auth_method: "private_key_jwt",
- jwks_uri: "https://kentshikama.com/api/openid_connect/jwks.json"
+ jwks_uri: "https://kentshikama.com/api/openid_connect/jwks.json"}
client_json = JSON.parse(response.body)
expect(client_json["client_id"].length).to eq(32)
expect(client_json["ppid"]).to eq(true)
@@ -113,9 +113,9 @@ describe Api::OpenidConnect::ClientsController, type: :controller, suppress_csrf
context "when redirect uri is missing" do
it "should return a invalid_client_metadata error" do
- post :create, response_types: [], grant_types: [], application_type: "web", contacts: [],
+ post :create, params: {response_types: [], grant_types: [], application_type: "web", contacts: [],
logo_uri: "http://example.com/logo.png", client_uri: "http://example.com/client",
- policy_uri: "http://example.com/policy", tos_uri: "http://example.com/tos"
+ policy_uri: "http://example.com/policy", tos_uri: "http://example.com/tos"}
client_json = JSON.parse(response.body)
expect(client_json["error"]).to have_content("invalid_client_metadata")
end
@@ -127,7 +127,7 @@ describe Api::OpenidConnect::ClientsController, type: :controller, suppress_csrf
context "when an OIDC client already exists" do
it "should return a client id" do
- get :find, client_name: client.client_name
+ get :find, params: {client_name: client.client_name}
client_id_json = JSON.parse(response.body)
expect(client_id_json["client_id"]).to eq(client.client_id)
end
@@ -135,7 +135,7 @@ describe Api::OpenidConnect::ClientsController, type: :controller, suppress_csrf
context "when an OIDC client doesn't already exist" do
it "should return the appropriate error" do
- get :find, client_name: "random_name"
+ get :find, params: {client_name: "random_name"}
client_id_json = JSON.parse(response.body)
expect(client_id_json["error"]).to eq("Client with name random_name does not exist")
end
diff --git a/spec/controllers/api/openid_connect/token_endpoint_controller_spec.rb b/spec/controllers/api/openid_connect/token_endpoint_controller_spec.rb
index c3a484085..766a3c806 100644
--- a/spec/controllers/api/openid_connect/token_endpoint_controller_spec.rb
+++ b/spec/controllers/api/openid_connect/token_endpoint_controller_spec.rb
@@ -3,13 +3,14 @@ describe Api::OpenidConnect::TokenEndpointController, type: :controller, suppres
describe "#create" do
it "returns 200 on success" do
- post :create,
- grant_type: "authorization_code",
- code: auth.create_code,
- redirect_uri: auth.redirect_uri,
- scope: auth.scopes.join(" "),
- client_id: auth.o_auth_application.client_id,
- client_secret: auth.o_auth_application.client_secret
+ post :create, params: {
+ grant_type: "authorization_code",
+ code: auth.create_code,
+ redirect_uri: auth.redirect_uri,
+ scope: auth.scopes.join(" "),
+ client_id: auth.o_auth_application.client_id,
+ client_secret: auth.o_auth_application.client_secret
+ }
expect(response.code).to eq("200")
end
end
diff --git a/spec/controllers/aspect_memberships_controller_spec.rb b/spec/controllers/aspect_memberships_controller_spec.rb
index 90e706e29..a577a613a 100644
--- a/spec/controllers/aspect_memberships_controller_spec.rb
+++ b/spec/controllers/aspect_memberships_controller_spec.rb
@@ -22,13 +22,13 @@ describe AspectMembershipsController, type: :controller do
end
it "succeeds" do
- post :create, format: :json, person_id: bob.person.id, aspect_id: @aspect1.id
+ post :create, params: {person_id: bob.person.id, aspect_id: @aspect1.id}, format: :json
expect(response).to be_success
end
it "creates an aspect membership" do
expect {
- post :create, format: :json, person_id: bob.person.id, aspect_id: @aspect1.id
+ post :create, params: {person_id: bob.person.id, aspect_id: @aspect1.id}, format: :json
}.to change {
alice.contact_for(bob.person).aspect_memberships.count
}.by(1)
@@ -38,29 +38,23 @@ describe AspectMembershipsController, type: :controller do
# argggg why?
alice.contacts.reload
expect {
- post :create, format: :json, person_id: @person.id, aspect_id: @aspect0.id
+ post :create, params: {person_id: @person.id, aspect_id: @aspect0.id}, format: :json
}.to change {
alice.contacts.size
}.by(1)
end
- it "failure flashes error" do
- expect(alice).to receive(:share_with).and_return(nil)
- post :create, format: :mobile, person_id: @person.id, aspect_id: @aspect0.id
- expect(flash[:error]).not_to be_blank
- end
-
it "does not 500 on a duplicate key error" do
- params = {format: :json, person_id: @person.id, aspect_id: @aspect0.id}
- post :create, params
- post :create, params
+ params = {person_id: @person.id, aspect_id: @aspect0.id}
+ post :create, params: params, format: :json
+ post :create, params: params, format: :json
expect(response.status).to eq(400)
expect(response.body).to eq(I18n.t("aspect_memberships.destroy.invalid_statement"))
end
context "json" do
it "returns the aspect membership" do
- post :create, format: :json, person_id: @person.id, aspect_id: @aspect0.id
+ post :create, params: {person_id: @person.id, aspect_id: @aspect0.id}, format: :json
contact = @controller.current_user.contact_for(@person)
expect(response.body).to eq(AspectMembershipPresenter.new(contact.aspect_memberships.first).base_hash.to_json)
@@ -68,7 +62,7 @@ describe AspectMembershipsController, type: :controller do
it "responds with an error message when the request failed" do
expect(alice).to receive(:share_with).and_return(nil)
- post :create, format: :json, person_id: @person.id, aspect_id: @aspect0.id
+ post :create, params: {person_id: @person.id, aspect_id: @aspect0.id}, format: :json
expect(response.status).to eq(409)
expect(response.body).to eq(I18n.t("aspects.add_to_aspect.failure"))
end
@@ -78,22 +72,14 @@ describe AspectMembershipsController, type: :controller do
describe "#destroy" do
it "removes contacts from an aspect" do
membership = alice.add_contact_to_aspect(@contact, @aspect1)
- delete :destroy, format: :json, id: membership.id
+ delete :destroy, params: {id: membership.id}, format: :json
expect(response).to be_success
@aspect1.reload
expect(@aspect1.contacts.to_a).not_to include @contact
end
- it "does not 500 on an html request" do
- membership = alice.add_contact_to_aspect(@contact, @aspect1)
- delete :destroy, id: membership.id
- expect(response).to redirect_to :back
- @aspect1.reload
- expect(@aspect1.contacts.to_a).not_to include @contact
- end
-
it "aspect membership does not exist" do
- delete :destroy, format: :json, id: 123
+ delete :destroy, params: {id: 123}, format: :json
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("aspect_memberships.destroy.no_membership"))
end
diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb
index 4278b078d..1f39d7312 100644
--- a/spec/controllers/aspects_controller_spec.rb
+++ b/spec/controllers/aspects_controller_spec.rb
@@ -16,11 +16,11 @@ describe AspectsController, :type => :controller do
describe "#show" do
it "succeeds" do
- get :show, 'id' => @alices_aspect_1.id.to_s
+ get :show, params: {id: @alices_aspect_1.id.to_s}
expect(response).to be_redirect
end
it 'redirects on an invalid id' do
- get :show, 'id' => 0
+ get :show, params: {id: 0}
expect(response).to be_redirect
end
end
@@ -29,12 +29,12 @@ describe AspectsController, :type => :controller do
context "with valid params" do
it "creates an aspect" do
expect(alice.aspects.count).to eq(2)
- post :create, aspect: {name: "new aspect"}
+ post :create, params: {aspect: {name: "new aspect"}}
expect(alice.reload.aspects.count).to eq(3)
end
it "returns the created aspect as json" do
- post :create, aspect: {name: "new aspect"}
+ post :create, params: {aspect: {name: "new aspect"}}
expect(JSON.parse(response.body)["id"]).to eq Aspect.find_by_name("new aspect").id
expect(JSON.parse(response.body)["name"]).to eq "new aspect"
end
@@ -42,19 +42,19 @@ describe AspectsController, :type => :controller do
context "with person_id param" do
it "creates a contact if one does not already exist" do
expect {
- post :create, format: "js", person_id: eve.person.id, aspect: {name: "new"}
+ post :create, params: {person_id: eve.person.id, aspect: {name: "new"}}, format: :js
}.to change {
alice.contacts.count
}.by(1)
end
it "adds a new contact to the new aspect" do
- post :create, format: "js", person_id: eve.person.id, aspect: {name: "new"}
+ post :create, params: {person_id: eve.person.id, aspect: {name: "new"}}, format: :js
expect(alice.aspects.find_by_name("new").contacts.count).to eq(1)
end
it "adds an existing contact to the new aspect" do
- post :create, format: "js", person_id: bob.person.id, aspect: {name: "new"}
+ post :create, params: {person_id: bob.person.id, aspect: {name: "new"}}, format: :js
expect(alice.aspects.find_by_name("new").contacts.count).to eq(1)
end
end
@@ -63,12 +63,12 @@ describe AspectsController, :type => :controller do
context "with invalid params" do
it "does not create an aspect" do
expect(alice.aspects.count).to eq(2)
- post :create, aspect: {name: ""}
+ post :create, params: {aspect: {name: ""}}
expect(alice.reload.aspects.count).to eq(2)
end
it "responds with 422" do
- post :create, aspect: {name: ""}
+ post :create, params: {aspect: {name: ""}}
expect(response.status).to eq(422)
end
end
@@ -83,13 +83,13 @@ describe AspectsController, :type => :controller do
new_user = FactoryGirl.create :user
params = {"name" => "Bruisers"}
params[:user_id] = new_user.id
- put('update', :id => @alices_aspect_1.id, "aspect" => params)
+ put :update, params: {id: @alices_aspect_1.id, aspect: params}
expect(Aspect.find(@alices_aspect_1.id).user_id).to eq(alice.id)
end
it "should return the name and id of the updated item" do
params = {"name" => "Bruisers"}
- put('update', :id => @alices_aspect_1.id, "aspect" => params)
+ put :update, params: {id: @alices_aspect_1.id, aspect: params}
expect(response.body).to eq({ :id => @alices_aspect_1.id, :name => "Bruisers" }.to_json)
end
end
@@ -100,7 +100,7 @@ describe AspectsController, :type => :controller do
@alices_aspect_2.update_attributes(order_id: 20)
ordered_aspect_ids = [@alices_aspect_2.id, @alices_aspect_1.id]
- put(:update_order, ordered_aspect_ids: ordered_aspect_ids)
+ put :update_order, params: {ordered_aspect_ids: ordered_aspect_ids}
expect(Aspect.find(@alices_aspect_1.id).order_id).to eq(1)
expect(Aspect.find(@alices_aspect_2.id).order_id).to eq(0)
@@ -115,12 +115,12 @@ describe AspectsController, :type => :controller do
context "with no auto follow back aspect" do
it "destoys the aspect" do
expect(alice.aspects.to_a).to include @alices_aspect_1
- post :destroy, id: @alices_aspect_1.id
+ post :destroy, params: {id: @alices_aspect_1.id}
expect(alice.reload.aspects.to_a).not_to include @alices_aspect_1
end
it "renders a flash message on success" do
- post :destroy, id: @alices_aspect_1.id
+ post :destroy, params: {id: @alices_aspect_1.id}
expect(flash[:notice]).to eq(I18n.t("aspects.destroy.success", name: @alices_aspect_1.name))
expect(flash[:error]).to be_blank
end
@@ -135,20 +135,20 @@ describe AspectsController, :type => :controller do
it "destoys the aspect" do
expect(alice.aspects.to_a).to include @alices_aspect_1
- post :destroy, id: @alices_aspect_1.id
+ post :destroy, params: {id: @alices_aspect_1.id}
expect(alice.reload.aspects.to_a).not_to include @alices_aspect_1
end
it "disables auto follow back" do
expect(alice.auto_follow_back).to be(true)
expect(alice.auto_follow_back_aspect).to eq(@alices_aspect_1)
- post :destroy, id: @alices_aspect_1.id
+ post :destroy, params: {id: @alices_aspect_1.id}
expect(alice.auto_follow_back).to be(false)
expect(alice.auto_follow_back_aspect).to eq(nil)
end
it "renders a flash message telling you to set a new auto follow back aspect" do
- post :destroy, id: @alices_aspect_1.id
+ post :destroy, params: {id: @alices_aspect_1.id}
expect(flash[:notice]).to eq(I18n.t("aspects.destroy.success_auto_follow_back", name: @alices_aspect_1.name))
expect(flash[:error]).to be_blank
end
@@ -160,7 +160,7 @@ describe AspectsController, :type => :controller do
@alices_aspect_1.contacts_visible = false
@alices_aspect_1.save
- xhr :get, :toggle_contact_visibility, :aspect_id => @alices_aspect_1.id
+ get :toggle_contact_visibility, xhr: true, params: {aspect_id: @alices_aspect_1.id}
expect(@alices_aspect_1.reload.contacts_visible).to be true
end
@@ -168,7 +168,7 @@ describe AspectsController, :type => :controller do
@alices_aspect_1.contacts_visible = true
@alices_aspect_1.save
- xhr :get, :toggle_contact_visibility, :aspect_id => @alices_aspect_1.id
+ get :toggle_contact_visibility, xhr: true, params: {aspect_id: @alices_aspect_1.id}
expect(@alices_aspect_1.reload.contacts_visible).to be false
end
end
diff --git a/spec/controllers/blocks_controller_spec.rb b/spec/controllers/blocks_controller_spec.rb
index de16662ea..93970e892 100644
--- a/spec/controllers/blocks_controller_spec.rb
+++ b/spec/controllers/blocks_controller_spec.rb
@@ -6,25 +6,18 @@ describe BlocksController, :type => :controller do
describe "#create" do
it "creates a block" do
expect {
- post :create, :block => {:person_id => eve.person.id}
+ post :create, params: {block: {person_id: eve.person.id}}, format: :json
}.to change { alice.blocks.count }.by(1)
end
- it "redirects back" do
- post :create, :block => { :person_id => 2 }
-
- expect(response).to be_redirect
- end
-
- it "notifies the user" do
- post :create, :block => { :person_id => 2 }
-
- expect(flash).not_to be_empty
+ it "responds with 204" do
+ post :create, params: {block: {person_id: eve.person.id}}, format: :json
+ expect(response.status).to eq(204)
end
it "calls #disconnect_if_contact" do
expect(@controller).to receive(:disconnect_if_contact).with(bob.person)
- post :create, :block => {:person_id => bob.person.id}
+ post :create, params: {block: {person_id: bob.person.id}}, format: :json
end
end
@@ -33,14 +26,14 @@ describe BlocksController, :type => :controller do
@block = alice.blocks.create(:person => eve.person)
end
- it "redirects back" do
- delete :destroy, :id => @block.id
- expect(response).to be_redirect
+ it "responds with 204" do
+ delete :destroy, params: {id: @block.id}, format: :json
+ expect(response.status).to eq(204)
end
it "removes a block" do
expect {
- delete :destroy, :id => @block.id
+ delete :destroy, params: {id: @block.id}, format: :json
}.to change { alice.blocks.count }.by(-1)
end
end
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb
index a155cf531..4b9e22ce5 100644
--- a/spec/controllers/comments_controller_spec.rb
+++ b/spec/controllers/comments_controller_spec.rb
@@ -21,13 +21,13 @@ describe CommentsController, :type => :controller do
end
it 'responds to format json' do
- post :create, comment_hash.merge(:format => 'json')
+ post :create, params: comment_hash, format: :json
expect(response.code).to eq('201')
expect(response.body).to match comment_hash[:text]
end
it 'responds to format mobile' do
- post :create, comment_hash.merge(:format => 'mobile')
+ post :create, params: comment_hash, format: :mobile
expect(response).to be_success
end
end
@@ -39,21 +39,21 @@ describe CommentsController, :type => :controller do
end
it 'comments' do
- post :create, comment_hash
+ post :create, params: comment_hash
expect(response.code).to eq('201')
end
it "doesn't overwrite author_id" do
new_user = FactoryGirl.create(:user)
comment_hash[:author_id] = new_user.person.id.to_s
- post :create, comment_hash
+ post :create, params: comment_hash
expect(Comment.find_by_text(comment_hash[:text]).author_id).to eq(alice.person.id)
end
it "doesn't overwrite id" do
old_comment = alice.comment!(@post, "hello")
comment_hash[:id] = old_comment.id
- post :create, comment_hash
+ post :create, params: comment_hash
expect(old_comment.reload.text).to eq('hello')
end
end
@@ -63,7 +63,7 @@ describe CommentsController, :type => :controller do
@post = eve.post :status_message, :text => 'GIANTS', :to => aspect_to_post
expect(alice).not_to receive(:comment)
- post :create, comment_hash
+ post :create, params: comment_hash
expect(response.code).to eq("404")
expect(response.body).to eq(I18n.t("comments.create.error"))
end
@@ -85,7 +85,7 @@ describe CommentsController, :type => :controller do
comment = bob.comment!(@message, "hey")
expect(bob).to receive(:retract).with(comment)
- delete :destroy, :format => "js", :post_id => 1, :id => comment.id
+ delete :destroy, params: {post_id: 1, id: comment.id}, format: :js
expect(response.status).to eq(204)
end
@@ -93,7 +93,7 @@ describe CommentsController, :type => :controller do
comment = alice.comment!(@message, "hey")
expect(bob).to receive(:retract).with(comment)
- delete :destroy, :format => "js", :post_id => 1, :id => comment.id
+ delete :destroy, params: {post_id: 1, id: comment.id}, format: :js
expect(response.status).to eq(204)
end
end
@@ -103,7 +103,7 @@ describe CommentsController, :type => :controller do
comment = alice.comment!(@message, "hey")
expect(alice).to receive(:retract).with(comment)
- delete :destroy, :format => "js", :post_id => 1, :id => comment.id
+ delete :destroy, params: {post_id: 1, id: comment.id}, format: :js
expect(response.status).to eq(204)
end
@@ -112,13 +112,13 @@ describe CommentsController, :type => :controller do
comment2 = eve.comment!(@message, "hey")
expect(alice).not_to receive(:retract).with(comment1)
- delete :destroy, :format => "js", :post_id => 1, :id => comment2.id
+ delete :destroy, params: {post_id: 1, id: comment2.id}, format: :js
expect(response.status).to eq(403)
end
end
it 'renders nothing and 404 on a nonexistent comment' do
- delete :destroy, :post_id => 1, :id => 343415
+ delete :destroy, params: {post_id: 1, id: 343_415}
expect(response.status).to eq(404)
expect(response.body.strip).to be_empty
end
@@ -131,19 +131,19 @@ describe CommentsController, :type => :controller do
end
it 'works for mobile' do
- get :index, :post_id => @message.id, :format => 'mobile'
+ get :index, params: {post_id: @message.id}, format: :mobile
expect(response).to be_success
end
it 'returns all the comments for a post' do
comments = [alice, bob, eve].map{ |u| u.comment!(@message, "hey") }
- get :index, :post_id => @message.id, :format => :json
+ get :index, params: {post_id: @message.id}, format: :json
expect(JSON.parse(response.body).map {|comment| comment["id"] }).to match_array(comments.map(&:id))
end
it 'returns a 404 on a nonexistent post' do
- get :index, :post_id => 235236, :format => :json
+ get :index, params: {post_id: 235_236}, format: :json
expect(response.status).to eq(404)
end
@@ -151,7 +151,7 @@ describe CommentsController, :type => :controller do
aspect_to_post = eve.aspects.where(:name => "generic").first
message = eve.post(:status_message, :text => "hey", :to => aspect_to_post.id)
bob.comment!(@message, "hey")
- get :index, :post_id => message.id, :format => :json
+ get :index, params: {post_id: message.id}, format: :json
expect(response.status).to eq(404)
end
end
diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb
index e12a97c3f..c50243264 100644
--- a/spec/controllers/contacts_controller_spec.rb
+++ b/spec/controllers/contacts_controller_spec.rb
@@ -11,7 +11,7 @@ describe ContactsController, :type => :controller do
describe '#index' do
context 'format mobile' do
it "succeeds" do
- get :index, :format => 'mobile'
+ get :index, format: :mobile
expect(response).to be_success
end
end
@@ -40,26 +40,26 @@ describe ContactsController, :type => :controller do
end
it "succeeds" do
- get :index, q: @person1.first_name, format: "json"
+ get :index, params: {q: @person1.first_name}, format: :json
expect(response).to be_success
end
it "responds with json" do
- get :index, q: @person1.first_name, format: "json"
+ get :index, params: {q: @person1.first_name}, format: :json
expect(response.body).to eq([@person1].to_json)
end
it "only returns contacts" do
- get :index, q: @person2.first_name, format: "json"
+ get :index, params: {q: @person2.first_name}, format: :json
expect(response.body).to eq([].to_json)
end
it "only returns mutual contacts when mutual parameter is true" do
- get :index, q: @person1.first_name, mutual: true, format: "json"
+ get :index, params: {q: @person1.first_name, mutual: true}, format: :json
expect(response.body).to eq([].to_json)
- get :index, q: @person2.first_name, mutual: true, format: "json"
+ get :index, params: {q: @person2.first_name, mutual: true}, format: :json
expect(response.body).to eq([].to_json)
- get :index, q: @person3.first_name, mutual: true, format: "json"
+ get :index, params: {q: @person3.first_name, mutual: true}, format: :json
expect(response.body).to eq([@person3].to_json)
end
end
@@ -67,7 +67,7 @@ describe ContactsController, :type => :controller do
context "for pagination on the contacts page" do
context "without parameters" do
it "returns contacts" do
- get :index, format: "json", page: "1"
+ get :index, params: {page: "1"}, format: :json
contact_ids = JSON.parse(response.body).map {|c| c["id"] }
expect(contact_ids.to_set).to eq(bob.contacts.map(&:id).to_set)
end
@@ -76,7 +76,7 @@ describe ContactsController, :type => :controller do
contact = bob.contacts.first
contact.update_attributes(receiving: false)
- get :index, format: "json", page: "1"
+ get :index, params: {params: {page: "1"}}, format: :json
contact_ids = JSON.parse(response.body).map {|c| c["id"] }
expect(contact_ids.to_set).to eq(bob.contacts.receiving.map(&:id).to_set)
expect(contact_ids).not_to include(contact.id)
@@ -90,13 +90,13 @@ describe ContactsController, :type => :controller do
end
it "returns all contacts (sharing and receiving)" do
- get :index, format: "json", page: "1", set: "all"
+ get :index, params: {page: "1", set: "all"}, format: :json
contact_ids = JSON.parse(response.body).map {|c| c["id"] }
expect(contact_ids.to_set).to eq(bob.contacts.map(&:id).to_set)
end
it "sorts contacts by receiving status" do
- get :index, format: "json", page: "1", set: "all"
+ get :index, params: {page: "1", set: "all"}, format: :json
contact_ids = JSON.parse(response.body).map {|c| c["id"] }
expect(contact_ids).to eq(bob.contacts.order("receiving DESC").map(&:id))
expect(contact_ids.last).to eq(bob.contacts.first.id)
@@ -111,16 +111,16 @@ describe ContactsController, :type => :controller do
end
it "returns all contacts" do
- get :index, format: "json", a_id: @aspect.id, page: "1"
+ get :index, params: {a_id: @aspect.id, page: "1"}, format: :json
contact_ids = JSON.parse(response.body).map {|c| c["id"] }
expect(contact_ids.to_set).to eq(bob.contacts.map(&:id).to_set)
end
it "sorts contacts by aspect memberships" do
- get :index, format: "json", a_id: @aspect.id, page: "1"
+ get :index, params: {a_id: @aspect.id, page: "1"}, format: :json
expect(JSON.parse(response.body).first["person"]["id"]).to eq(@person.id)
- get :index, format: "json", a_id: bob.aspects.first.id, page: "1"
+ get :index, params: {a_id: bob.aspects.first.id, page: "1"}, format: :json
expect(JSON.parse(response.body).first["person"]["id"]).not_to eq(@person.id)
end
end
diff --git a/spec/controllers/conversation_visibilities_controller_spec.rb b/spec/controllers/conversation_visibilities_controller_spec.rb
index 5b8893c1e..973873e48 100644
--- a/spec/controllers/conversation_visibilities_controller_spec.rb
+++ b/spec/controllers/conversation_visibilities_controller_spec.rb
@@ -19,7 +19,7 @@ describe ConversationVisibilitiesController, :type => :controller do
describe '#destroy' do
it 'deletes the visibility' do
expect {
- delete :destroy, :conversation_id => @conversation.id
+ delete :destroy, params: {conversation_id: @conversation.id}
}.to change(ConversationVisibility, :count).by(-1)
end
@@ -28,20 +28,20 @@ describe ConversationVisibilitiesController, :type => :controller do
sign_in user2, scope: :user
expect {
- delete :destroy, :conversation_id => @conversation.id
+ delete :destroy, params: {conversation_id: @conversation.id}
}.not_to change(ConversationVisibility, :count)
end
it 'returns "hidden"' do
- get :destroy, :conversation_id => @conversation.id
+ get :destroy, params: {conversation_id: @conversation.id}
expect(flash.notice).to include("hidden")
end
it 'returns "deleted" when last participant' do
- get :destroy, :conversation_id => @conversation.id
+ get :destroy, params: {conversation_id: @conversation.id}
sign_out :user
sign_in bob, scope: :user
- get :destroy, :conversation_id => @conversation.id
+ get :destroy, params: {conversation_id: @conversation.id}
expect(flash.notice).to include("deleted")
end
end
diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb
index 9bf0c6cc1..dd6b64677 100644
--- a/spec/controllers/conversations_controller_spec.rb
+++ b/spec/controllers/conversations_controller_spec.rb
@@ -17,17 +17,17 @@ describe ConversationsController, :type => :controller do
describe "#new modal" do
context "desktop" do
it "succeeds" do
- get :new, modal: true
+ get :new, params: {modal: true}
expect(response).to be_success
end
it "assigns a contact if passed a contact id" do
- get :new, contact_id: alice.contacts.first.id, modal: true
+ get :new, params: {contact_id: alice.contacts.first.id, modal: true}
expect(controller.gon.conversation_prefill).to eq([alice.contacts.first.person.as_json])
end
it "assigns a set of contacts if passed an aspect id" do
- get :new, aspect_id: alice.aspects.first.id, modal: true
+ get :new, params: {aspect_id: alice.aspects.first.id, modal: true}
expect(controller.gon.conversation_prefill).to eq(alice.aspects.first.contacts.map {|c| c.person.as_json })
end
end
@@ -40,7 +40,7 @@ describe ConversationsController, :type => :controller do
it "assigns a json list of contacts that are sharing with the person" do
sharing_user = FactoryGirl.create(:user_with_aspect)
sharing_user.share_with(alice.person, sharing_user.aspects.first)
- get :new, modal: true
+ get :new, params: {modal: true}
expect(assigns(:contacts_json))
.to include(alice.contacts.where(sharing: true, receiving: true).first.person.name)
alice.contacts << Contact.new(person_id: eve.person.id, user_id: alice.id, sharing: false, receiving: true)
@@ -51,7 +51,7 @@ describe ConversationsController, :type => :controller do
it "does not allow XSS via the name parameter" do
["",
'"}]});alert(1);(function f() {var foo = [{b:"'].each do |xss|
- get :new, modal: true, name: xss
+ get :new, params: {modal: true, name: xss}
expect(response.body).not_to include xss
end
end
@@ -60,7 +60,7 @@ describe ConversationsController, :type => :controller do
xss = ""
contact = alice.contacts.first
contact.person.profile.update_attribute(:first_name, xss)
- get :new, modal: true
+ get :new, params: {modal: true}
json = JSON.parse(assigns(:contacts_json)).first
expect(json["value"].to_s).to eq(contact.id.to_s)
expect(json["name"]).to_not include(xss)
@@ -101,7 +101,7 @@ describe ConversationsController, :type => :controller do
end
it "retrieves a conversation" do
- get :index, conversation_id: @conversations.first.id
+ get :index, params: {conversation_id: @conversations.first.id}
expect(response).to be_success
expect(assigns[:visibilities]).to match_array(@visibilities)
expect(assigns[:conversation]).to eq(@conversations.first)
@@ -109,7 +109,7 @@ describe ConversationsController, :type => :controller do
it "does not let you access conversations where you are not a recipient" do
sign_in eve, scope: :user
- get :index, conversation_id: @conversations.first.id
+ get :index, params: {conversation_id: @conversations.first.id}
expect(assigns[:conversation]).to be_nil
end
@@ -125,31 +125,30 @@ describe ConversationsController, :type => :controller do
describe "#create" do
context "desktop" do
context "with a valid conversation" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: "text debug"},
person_ids: alice.contacts.first.person.id.to_s
}
- end
+ }
it "creates a conversation" do
- expect { post :create, @hash }.to change(Conversation, :count).by(1)
+ expect { post :create, params: params, format: :js }.to change(Conversation, :count).by(1)
end
it "creates a message" do
- expect { post :create, @hash }.to change(Message, :count).by(1)
+ expect { post :create, params: params, format: :js }.to change(Message, :count).by(1)
end
it "responds with the conversation id as JSON" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).to be_success
expect(JSON.parse(response.body)["id"]).to eq(Conversation.first.id)
end
it "sets the author to the current_user" do
- @hash[:author] = FactoryGirl.create(:user)
- post :create, @hash
+ params[:author] = FactoryGirl.create(:user)
+ post :create, params: params, format: :js
expect(Message.first.author).to eq(alice.person)
expect(Conversation.first.author).to eq(alice.person)
end
@@ -159,130 +158,128 @@ describe ConversationsController, :type => :controller do
subject: "not spam", messages_attributes: [{author: alice.person, text: "cool stuff"}])
expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch)
- post :create, @hash
+ post :create, params: params, format: :js
end
end
context "with empty subject" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: " ", text: "text debug"},
person_ids: alice.contacts.first.person.id.to_s
}
- end
+ }
it "creates a conversation" do
- expect { post :create, @hash }.to change(Conversation, :count).by(1)
+ expect { post :create, params: params, format: :js }.to change(Conversation, :count).by(1)
end
it "creates a message" do
- expect { post :create, @hash }.to change(Message, :count).by(1)
+ expect { post :create, params: params, format: :js }.to change(Message, :count).by(1)
end
it "responds with the conversation id as JSON" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).to be_success
expect(JSON.parse(response.body)["id"]).to eq(Conversation.first.id)
end
end
context "with empty text" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: " "},
person_ids: alice.contacts.first.person.id.to_s
}
- end
+ }
it "does not create a conversation" do
- expect { post :create, @hash }.not_to change(Conversation, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Conversation, :count)
end
it "does not create a message" do
- expect { post :create, @hash }.not_to change(Message, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Message, :count)
end
it "responds with an error message" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("conversations.create.fail"))
end
end
context "with empty contact" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: "text debug"},
person_ids: " "
}
- end
+ }
it "does not create a conversation" do
- expect { post :create, @hash }.not_to change(Conversation, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Conversation, :count)
end
it "does not create a message" do
- expect { post :create, @hash }.not_to change(Message, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Message, :count)
end
it "responds with an error message" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("javascripts.conversation.create.no_recipient"))
end
end
context "with nil contact" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: "text debug"},
person_ids: nil
}
- end
+ }
it "does not create a conversation" do
- expect { post :create, @hash }.not_to change(Conversation, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Conversation, :count)
end
it "does not create a message" do
- expect { post :create, @hash }.not_to change(Message, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Message, :count)
end
it "responds with an error message" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("javascripts.conversation.create.no_recipient"))
end
end
context "with non-mutual contact" do
- before do
- @person1 = FactoryGirl.create(:person)
- @person2 = FactoryGirl.create(:person)
- alice.contacts.create!(receiving: false, sharing: true, person: @person2)
- @person3 = FactoryGirl.create(:person)
- alice.contacts.create!(receiving: true, sharing: false, person: @person3)
- @hash = {
- format: :js,
+ let(:person1) { FactoryGirl.create(:person) }
+ let(:person2) { FactoryGirl.create(:person) }
+ let(:person3) { FactoryGirl.create(:person) }
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: "text debug"},
- person_ids: [@person1.id, @person2.id, @person3.id].join(",")
+ person_ids: [person1.id, person2.id, person3.id].join(",")
}
+ }
+
+ before do
+ alice.contacts.create!(receiving: false, sharing: true, person: person2)
+ alice.contacts.create!(receiving: true, sharing: false, person: person3)
end
it "does not create a conversation" do
- expect { post :create, @hash }.not_to change(Conversation, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Conversation, :count)
end
it "does not create a message" do
- expect { post :create, @hash }.not_to change(Message, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Message, :count)
end
it "responds with an error message" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("javascripts.conversation.create.no_recipient"))
end
@@ -295,31 +292,30 @@ describe ConversationsController, :type => :controller do
end
context "with a valid conversation" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: "text debug"},
contact_ids: alice.contacts.first.id.to_s
}
- end
+ }
it "creates a conversation" do
- expect { post :create, @hash }.to change(Conversation, :count).by(1)
+ expect { post :create, params: params, format: :js }.to change(Conversation, :count).by(1)
end
it "creates a message" do
- expect { post :create, @hash }.to change(Message, :count).by(1)
+ expect { post :create, params: params, format: :js }.to change(Message, :count).by(1)
end
it "responds with the conversation id as JSON" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).to be_success
expect(JSON.parse(response.body)["id"]).to eq(Conversation.first.id)
end
it "sets the author to the current_user" do
- @hash[:author] = FactoryGirl.create(:user)
- post :create, @hash
+ params[:author] = FactoryGirl.create(:user)
+ post :create, params: params, format: :js
expect(Message.first.author).to eq(alice.person)
expect(Conversation.first.author).to eq(alice.person)
end
@@ -329,127 +325,122 @@ describe ConversationsController, :type => :controller do
subject: "not spam", messages_attributes: [{author: alice.person, text: "cool stuff"}])
expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch)
- post :create, @hash
+ post :create, params: params, format: :js
end
end
context "with empty subject" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: " ", text: "text debug"},
contact_ids: alice.contacts.first.id.to_s
}
- end
+ }
it "creates a conversation" do
- expect { post :create, @hash }.to change(Conversation, :count).by(1)
+ expect { post :create, params: params, format: :js }.to change(Conversation, :count).by(1)
end
it "creates a message" do
- expect { post :create, @hash }.to change(Message, :count).by(1)
+ expect { post :create, params: params, format: :js }.to change(Message, :count).by(1)
end
it "responds with the conversation id as JSON" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).to be_success
expect(JSON.parse(response.body)["id"]).to eq(Conversation.first.id)
end
end
context "with empty text" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: " "},
contact_ids: alice.contacts.first.id.to_s
}
- end
+ }
it "does not create a conversation" do
- expect { post :create, @hash }.not_to change(Conversation, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Conversation, :count)
end
it "does not create a message" do
- expect { post :create, @hash }.not_to change(Message, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Message, :count)
end
it "responds with an error message" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("conversations.create.fail"))
end
end
context "with empty contact" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: "text debug"},
contact_ids: " "
}
- end
+ }
it "does not create a conversation" do
- expect { post :create, @hash }.not_to change(Conversation, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Conversation, :count)
end
it "does not create a message" do
- expect { post :create, @hash }.not_to change(Message, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Message, :count)
end
it "responds with an error message" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("javascripts.conversation.create.no_recipient"))
end
end
context "with nil contact" do
- before do
- @hash = {
- format: :js,
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: "text debug"},
contact_ids: nil
}
- end
+ }
it "does not create a conversation" do
- expect { post :create, @hash }.not_to change(Conversation, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Conversation, :count)
end
it "does not create a message" do
- expect { post :create, @hash }.not_to change(Message, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Message, :count)
end
it "responds with an error message" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("javascripts.conversation.create.no_recipient"))
end
end
context "with non-mutual contact" do
- before do
- @contact1 = alice.contacts.create(receiving: false, sharing: true, person: FactoryGirl.create(:person))
- @contact2 = alice.contacts.create(receiving: true, sharing: false, person: FactoryGirl.create(:person))
- @hash = {
- format: :js,
+ let(:contact1) { alice.contacts.create(receiving: false, sharing: true, person: FactoryGirl.create(:person)) }
+ let(:contact2) { alice.contacts.create(receiving: true, sharing: false, person: FactoryGirl.create(:person)) }
+ let(:params) {
+ {
conversation: {subject: "secret stuff", text: "text debug"},
- person_ids: [@contact1.id, @contact2.id].join(",")
+ contact_ids: [contact1.id, contact2.id].join(",")
}
- end
+ }
it "does not create a conversation" do
- expect { post :create, @hash }.not_to change(Conversation, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Conversation, :count)
end
it "does not create a message" do
- expect { post :create, @hash }.not_to change(Message, :count)
+ expect { post :create, params: params, format: :js }.not_to change(Message, :count)
end
it "responds with an error message" do
- post :create, @hash
+ post :create, params: params, format: :js
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("javascripts.conversation.create.no_recipient"))
end
@@ -458,47 +449,45 @@ describe ConversationsController, :type => :controller do
end
describe "#show" do
- before do
- hash = {
+ let(:conversation) {
+ Conversation.create(
author: alice.person,
participant_ids: [alice.contacts.first.person.id, alice.person.id],
subject: "not spam",
messages_attributes: [{author: alice.person, text: "cool stuff"}]
- }
- @conversation = Conversation.create(hash)
- end
+ )
+ }
it "succeeds with json" do
- get :show, :id => @conversation.id, :format => :json
+ get :show, params: {id: conversation.id}, format: :json
expect(response).to be_success
- expect(assigns[:conversation]).to eq(@conversation)
- expect(response.body).to include @conversation.guid
+ expect(assigns[:conversation]).to eq(conversation)
+ expect(response.body).to include conversation.guid
end
it "redirects to index" do
- get :show, :id => @conversation.id
- expect(response).to redirect_to(conversations_path(:conversation_id => @conversation.id))
+ get :show, params: {id: conversation.id}
+ expect(response).to redirect_to(conversations_path(conversation_id: conversation.id))
end
end
describe "#raw" do
- before do
- hash = {
+ let(:conversation) {
+ Conversation.create(
author: alice.person,
participant_ids: [alice.contacts.first.person.id, alice.person.id],
subject: "not spam",
messages_attributes: [{author: alice.person, text: "cool stuff"}]
- }
- @conversation = Conversation.create(hash)
- end
+ )
+ }
it "returns html of conversation" do
- get :raw, conversation_id: @conversation.id
- expect(response).to render_template(partial: "show", locals: {conversation: @conversation})
+ get :raw, params: {conversation_id: conversation.id}
+ expect(response).to render_template(partial: "show", locals: {conversation: conversation})
end
it "returns 404 when requesting non-existant conversation" do
- get :raw, conversation_id: -1
+ get :raw, params: {conversation_id: -1}
expect(response).to have_http_status(404)
end
end
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb
index b40bcbbaa..a9c3b0a1a 100644
--- a/spec/controllers/help_controller_spec.rb
+++ b/spec/controllers/help_controller_spec.rb
@@ -8,7 +8,7 @@ describe HelpController, type: :controller do
it "fails on mobile" do
expect {
get :faq, format: :mobile
- }.to raise_error ActionView::MissingTemplate
+ }.to raise_error ActionController::UnknownFormat
end
end
end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index 80b9bc023..2e5a9b3a8 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -40,7 +40,7 @@ describe HomeController, type: :controller do
it "redirects to the stream if the user is signed in" do
sign_in alice
- get :show, home: true
+ get :show
expect(response).to redirect_to(stream_path)
end
end
diff --git a/spec/controllers/invitation_codes_controller_spec.rb b/spec/controllers/invitation_codes_controller_spec.rb
index 90864fefc..afc317f99 100644
--- a/spec/controllers/invitation_codes_controller_spec.rb
+++ b/spec/controllers/invitation_codes_controller_spec.rb
@@ -1,7 +1,7 @@
describe InvitationCodesController, type: :controller do
describe "#show" do
it "redirects to the root page if the invitation code is invalid" do
- get :show, id: "InvalidInvitationCode"
+ get :show, params: {id: "InvalidInvitationCode"}
expect(response).to redirect_to root_path
expect(flash[:notice]).to eq(I18n.t("invitation_codes.not_valid"))
end
@@ -10,13 +10,13 @@ describe InvitationCodesController, type: :controller do
let(:invitation_token) { alice.invitation_code.token }
it "redirects logged out users to the sign in page" do
- post :show, id: invitation_token
+ post :show, params: {id: invitation_token}
expect(response).to redirect_to new_user_registration_path(invite: {token: invitation_token})
end
it "redirects logged in users the the inviters page" do
sign_in bob
- post :show, id: invitation_token
+ post :show, params: {id: invitation_token}
expect(response).to redirect_to person_path(alice.person)
expect(flash[:notice]).to eq(I18n.t("invitation_codes.already_logged_in", inviter: alice.name))
end
diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb
index 7fb2b03fb..9ca17c125 100644
--- a/spec/controllers/invitations_controller_spec.rb
+++ b/spec/controllers/invitations_controller_spec.rb
@@ -17,16 +17,16 @@ describe InvitationsController, type: :controller do
it "does not create an EmailInviter" do
expect(Workers::Mail::InviteEmail).not_to receive(:perform_async)
- post :create, invite_params
+ post :create, params: invite_params
end
it "returns to the previous page" do
- post :create, invite_params
+ post :create, params: invite_params
expect(response).to redirect_to referer
end
it "flashes an error" do
- post :create, invite_params
+ post :create, params: invite_params
expect(flash[:error]).to eq(I18n.t("invitations.create.empty"))
end
end
@@ -39,16 +39,16 @@ describe InvitationsController, type: :controller do
expect(Workers::Mail::InviteEmail).to receive(:perform_async).with(
emails, alice.id, invite_params[:email_inviter]
)
- post :create, invite_params
+ post :create, params: invite_params
end
it "returns to the previous page on success" do
- post :create, invite_params
+ post :create, params: invite_params
expect(response).to redirect_to referer
end
it "flashes a notice" do
- post :create, invite_params
+ post :create, params: invite_params
expected = I18n.t("invitations.create.sent", emails: emails)
expect(flash[:notice]).to eq(expected)
end
@@ -60,16 +60,16 @@ describe InvitationsController, type: :controller do
it "does not create an InviteEmail worker" do
expect(Workers::Mail::InviteEmail).not_to receive(:perform_async)
- post :create, invite_params
+ post :create, params: invite_params
end
it "returns to the previous page" do
- post :create, invite_params
+ post :create, params: invite_params
expect(response).to redirect_to referer
end
it "flashes an error" do
- post :create, invite_params
+ post :create, params: invite_params
expected = I18n.t("invitations.create.rejected", emails: emails)
expect(flash[:error]).to eq(expected)
@@ -85,16 +85,16 @@ describe InvitationsController, type: :controller do
expect(Workers::Mail::InviteEmail).to receive(:perform_async).with(
valid_emails, alice.id, invite_params[:email_inviter]
)
- post :create, invite_params
+ post :create, params: invite_params
end
it "returns to the previous page" do
- post :create, invite_params
+ post :create, params: invite_params
expect(response).to redirect_to referer
end
it "flashes a notice" do
- post :create, invite_params
+ post :create, params: invite_params
expected = I18n.t("invitations.create.sent", emails: valid_emails.split(",").join(", ")) + ". " +
I18n.t("invitations.create.rejected", emails: invalid_emails)
expect(flash[:error]).to eq(expected)
@@ -109,7 +109,7 @@ describe InvitationsController, type: :controller do
it "displays an error if invitations are closed" do
AppConfig.settings.invitations.open = false
- post :create, invite_params
+ post :create, params: invite_params
expect(flash[:error]).to eq(I18n.t("invitations.create.closed"))
end
@@ -117,7 +117,7 @@ describe InvitationsController, type: :controller do
it "displays an error when no invitations are left" do
alice.invitation_code.update_attributes(count: 0)
- post :create, invite_params
+ post :create, params: invite_params
expect(flash[:error]).to eq(I18n.t("invitations.create.no_more"))
end
@@ -127,7 +127,7 @@ describe InvitationsController, type: :controller do
AppConfig.settings.invitations.open = false
alice.invitation_code.update_attributes(count: 0)
- post :create, invite_params
+ post :create, params: invite_params
expect(flash[:error]).to be_nil
end
diff --git a/spec/controllers/jasmine_fixtures/aspects_spec.rb b/spec/controllers/jasmine_fixtures/aspects_spec.rb
index e2adf493d..b82fbc2de 100644
--- a/spec/controllers/jasmine_fixtures/aspects_spec.rb
+++ b/spec/controllers/jasmine_fixtures/aspects_spec.rb
@@ -22,14 +22,14 @@ describe StreamsController, :type => :controller do
end
it "generates a jasmine fixture with a prefill", :fixture => true do
- get :aspects, :prefill => "reshare things"
+ get :aspects, params: {prefill: "reshare things"}
save_fixture(html_for("body"), "aspects_index_prefill")
end
it 'generates a jasmine fixture with services', :fixture => true do
alice.services << Services::Facebook.create(:user_id => alice.id)
alice.services << Services::Twitter.create(:user_id => alice.id)
- get :aspects, :prefill => "reshare things"
+ get :aspects, params: {prefill: "reshare things"}
save_fixture(html_for("body"), "aspects_index_services")
end
@@ -44,7 +44,7 @@ describe StreamsController, :type => :controller do
it 'generates a jasmine fixture with only posts', :fixture => true do
2.times { bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.where(:name => "generic").first.id) }
- get :aspects, :only_posts => true
+ get :aspects, params: {only_posts: true}
save_fixture(response.body, "aspects_index_only_posts")
end
diff --git a/spec/controllers/jasmine_fixtures/contacts_spec.rb b/spec/controllers/jasmine_fixtures/contacts_spec.rb
index 127f9be2a..06262aed2 100644
--- a/spec/controllers/jasmine_fixtures/contacts_spec.rb
+++ b/spec/controllers/jasmine_fixtures/contacts_spec.rb
@@ -13,12 +13,12 @@ describe ContactsController, :type => :controller do
end
it "generates the aspects_manage fixture", :fixture => true do
- get :index, :a_id => @aspect.id
+ get :index, params: {a_id: @aspect.id}
save_fixture(html_for("body"), "aspects_manage")
end
it "generates the aspects_manage_contacts_json fixture", fixture: true do
- get :index, format: :json, a_id: @aspect.id, page: "1"
+ get :index, params: {a_id: @aspect.id, page: "1"}, format: :json
save_fixture(response.body, "aspects_manage_contacts_json")
end
diff --git a/spec/controllers/jasmine_fixtures/conversations_spec.rb b/spec/controllers/jasmine_fixtures/conversations_spec.rb
index cfba3708b..a35993c0b 100644
--- a/spec/controllers/jasmine_fixtures/conversations_spec.rb
+++ b/spec/controllers/jasmine_fixtures/conversations_spec.rb
@@ -22,10 +22,10 @@ describe ConversationsController, :type => :controller do
end
it "generates a jasmine fixture", :fixture => true do
- get :index, :conversation_id => @conv1.id
+ get :index, params: {conversation_id: @conv1.id}
save_fixture(html_for("body"), "conversations_unread")
- get :index, :conversation_id => @conv1.id
+ get :index, params: {conversation_id: @conv1.id}
save_fixture(html_for("body"), "conversations_read")
end
end
diff --git a/spec/controllers/jasmine_fixtures/people_spec.rb b/spec/controllers/jasmine_fixtures/people_spec.rb
index 432ff5d5c..77ec78424 100644
--- a/spec/controllers/jasmine_fixtures/people_spec.rb
+++ b/spec/controllers/jasmine_fixtures/people_spec.rb
@@ -14,7 +14,7 @@ describe PeopleController, :type => :controller do
end
it "generates a jasmine fixture trying an external search", :fixture => true do
- get :index, :q => "sample@diaspor.us"
+ get :index, params: {q: "sample@diaspor.us"}
save_fixture(html_for("body"), "pending_external_people_search")
end
end
diff --git a/spec/controllers/jasmine_fixtures/photos_spec.rb b/spec/controllers/jasmine_fixtures/photos_spec.rb
index fd62b21a6..3dabe5e53 100644
--- a/spec/controllers/jasmine_fixtures/photos_spec.rb
+++ b/spec/controllers/jasmine_fixtures/photos_spec.rb
@@ -11,7 +11,7 @@ describe PhotosController, :type => :controller do
describe '#index' do
it "generates a jasmine fixture", :fixture => true do
request.env['HTTP_ACCEPT'] = 'application/json'
- get :index, :person_id => alice.person.guid.to_s
+ get :index, params: {person_id: alice.person.guid.to_s}
save_fixture(response.body, "photos_json")
end
end
diff --git a/spec/controllers/jasmine_fixtures/status_messages_spec.rb b/spec/controllers/jasmine_fixtures/status_messages_spec.rb
index 905a5137c..6964f1d5b 100644
--- a/spec/controllers/jasmine_fixtures/status_messages_spec.rb
+++ b/spec/controllers/jasmine_fixtures/status_messages_spec.rb
@@ -25,7 +25,7 @@ describe StatusMessagesController, :type => :controller do
aspect = alice.aspects.create(:name => 'people')
contact.aspects << aspect
contact.save
- get :new, :person_id => bob.person.id
+ get :new, params: {person_id: bob.person.id}
save_fixture(html_for("body"), "status_message_new")
end
end
diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb
index b9935a70f..b29fdeae9 100644
--- a/spec/controllers/likes_controller_spec.rb
+++ b/spec/controllers/likes_controller_spec.rb
@@ -18,7 +18,7 @@ describe LikesController, type: :controller do
context "on my own post" do
it "succeeds" do
@target = alice.post :status_message, text: "AWESOME", to: @alices_aspect.id
- post :create, like_hash.merge(format: :json)
+ post :create, params: like_hash, format: :json
expect(response.code).to eq("201")
end
end
@@ -29,13 +29,13 @@ describe LikesController, type: :controller do
end
it "likes" do
- post :create, like_hash
+ post :create, params: like_hash
expect(response.code).to eq("201")
end
it "doesn't post multiple times" do
alice.like!(@target)
- post :create, like_hash
+ post :create, params: like_hash
expect(response.code).to eq("422")
end
end
@@ -47,7 +47,7 @@ describe LikesController, type: :controller do
it "doesn't post" do
expect(alice).not_to receive(:like!)
- post :create, like_hash
+ post :create, params: like_hash
expect(response.code).to eq("422")
end
end
@@ -58,8 +58,7 @@ describe LikesController, type: :controller do
end
it "should be catched when it means that the target is not found" do
- params = like_hash.merge(format: :json, post_id: -1)
- post :create, params
+ post :create, params: {post_id: -1}, format: :json
expect(response.code).to eq("422")
end
@@ -67,7 +66,7 @@ describe LikesController, type: :controller do
@target = alice.post :status_message, text: "AWESOME", to: @alices_aspect.id
allow(alice).to receive(:like!).and_raise("something")
allow(@controller).to receive(:current_user).and_return(alice)
- expect { post :create, like_hash.merge(format: :json) }.to raise_error("something")
+ expect { post :create, params: like_hash, format: :json }.to raise_error("something")
end
end
end
@@ -80,18 +79,18 @@ describe LikesController, type: :controller do
it "returns a 404 for a post not visible to the user" do
sign_in eve
expect {
- get :index, post_id: @message.id
+ get :index, params: {post_id: @message.id}
}.to raise_error(ActiveRecord::RecordNotFound)
end
it "returns an array of likes for a post" do
bob.like!(@message)
- get :index, post_id: @message.id
+ get :index, params: {post_id: @message.id}
expect(JSON.parse(response.body).map {|h| h["id"] }).to match_array(@message.likes.map(&:id))
end
it "returns an empty array for a post with no likes" do
- get :index, post_id: @message.id
+ get :index, params: {post_id: @message.id}
expect(JSON.parse(response.body).map(&:id)).to eq([])
end
end
@@ -106,7 +105,7 @@ describe LikesController, type: :controller do
current_user = controller.send(:current_user)
expect(current_user).to receive(:retract).with(@like)
- delete :destroy, format: :json, post_id: @message.id, id: @like.id
+ delete :destroy, params: {post_id: @message.id, id: @like.id}, format: :json
expect(response.status).to eq(204)
end
@@ -114,7 +113,7 @@ describe LikesController, type: :controller do
like2 = eve.like!(@message)
like_count = Like.count
- delete :destroy, format: :json, post_id: @message.id, id: like2.id
+ delete :destroy, params: {post_id: @message.id, id: like2.id}, format: :json
expect(response.status).to eq(404)
expect(response.body).to eq(I18n.t("likes.destroy.error"))
expect(Like.count).to eq(like_count)
diff --git a/spec/controllers/messages_controller_spec.rb b/spec/controllers/messages_controller_spec.rb
index 6e7bea228..596ca084e 100644
--- a/spec/controllers/messages_controller_spec.rb
+++ b/spec/controllers/messages_controller_spec.rb
@@ -32,7 +32,7 @@ describe MessagesController, :type => :controller do
it 'redirects to conversation' do
expect {
- post :create, @message_params
+ post :create, params: @message_params
}.to change(Message, :count).by(1)
expect(response.status).to eq(302)
expect(response).to redirect_to(conversations_path(:conversation_id => @conversation))
@@ -40,7 +40,7 @@ describe MessagesController, :type => :controller do
it "dispatches the message" do
expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch).with(alice, instance_of(Message))
- post :create, @message_params
+ post :create, params: @message_params
end
end
@@ -54,7 +54,7 @@ describe MessagesController, :type => :controller do
it 'does not create the message' do
expect {
- post :create, @message_params
+ post :create, params: @message_params
}.not_to change(Message, :count)
expect(flash[:error]).to be_present
end
@@ -72,7 +72,7 @@ describe MessagesController, :type => :controller do
end
it 'comments' do
- post :create, @message_params
+ post :create, params: @message_params
expect(response.status).to eq(302)
expect(response).to redirect_to(conversations_path(:conversation_id => @conversation))
end
@@ -81,7 +81,7 @@ describe MessagesController, :type => :controller do
new_user = FactoryGirl.create(:user)
@message_params[:author_id] = new_user.person.id.to_s
- post :create, @message_params
+ post :create, params: @message_params
created_message = Message.find_by_text(@message_params[:message][:text])
expect(created_message.author).to eq(alice.person)
end
@@ -94,13 +94,13 @@ describe MessagesController, :type => :controller do
)
@message_params[:id] = old_message.id
- post :create, @message_params
+ post :create, params: @message_params
expect(old_message.reload.text).to eq('hello')
end
it "dispatches the message" do
expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch).with(alice, instance_of(Message))
- post :create, @message_params
+ post :create, params: @message_params
end
end
@@ -118,7 +118,7 @@ describe MessagesController, :type => :controller do
it 'does not create the message' do
expect {
- post :create, @message_params
+ post :create, params: @message_params
}.not_to change(Message, :count)
expect(flash[:error]).to be_present
end
diff --git a/spec/controllers/node_info_controller_spec.rb b/spec/controllers/node_info_controller_spec.rb
index 907f1183a..3108ca4cf 100644
--- a/spec/controllers/node_info_controller_spec.rb
+++ b/spec/controllers/node_info_controller_spec.rb
@@ -25,7 +25,7 @@ describe NodeInfoController do
describe "#document" do
context "invalid version" do
it "responds with not found" do
- get :document, version: "0.0", format: :json
+ get :document, params: {version: "0.0"}, format: :json
expect(response.code).to eq "404"
end
@@ -34,7 +34,7 @@ describe NodeInfoController do
%w(1.0 2.0).each do |version|
context "version #{version}" do
it "responds to JSON" do
- get :document, version: version, format: :json
+ get :document, params: {version: version}, format: :json
expect(response).to be_success
end
@@ -43,11 +43,11 @@ describe NodeInfoController do
expect(NodeInfoPresenter).to receive(:new).with(version)
.and_return(double(as_json: {}, content_type: "application/json"))
- get :document, version: version, format: :json
+ get :document, params: {version: version}, format: :json
end
it "notes the schema in the content type" do
- get :document, version: version, format: :json
+ get :document, params: {version: version}, format: :json
expect(response.content_type)
.to eq("application/json; profile=http://nodeinfo.diaspora.software/ns/schema/#{version}#")
diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb
index d1f969e7a..58a078bcb 100644
--- a/spec/controllers/notifications_controller_spec.rb
+++ b/spec/controllers/notifications_controller_spec.rb
@@ -10,23 +10,23 @@ describe NotificationsController, :type => :controller do
describe '#update' do
it 'marks a notification as read if it gets no other information' do
note = FactoryGirl.create(:notification)
- expect(Notification).to receive( :where ).and_return( [note] )
- expect(note).to receive( :set_read_state ).with( true )
- get :update, "id" => note.id, :format => :json
+ expect(Notification).to receive(:where).and_return([note])
+ expect(note).to receive(:set_read_state).with(true)
+ get :update, params: {id: note.id}, format: :json
end
it 'marks a notification as read if it is told to' do
note = FactoryGirl.create(:notification)
- expect(Notification).to receive( :where ).and_return( [note] )
- expect(note).to receive( :set_read_state ).with( true )
- get :update, "id" => note.id, :set_unread => "false", :format => :json
+ expect(Notification).to receive(:where).and_return([note])
+ expect(note).to receive(:set_read_state).with(true)
+ get :update, params: {id: note.id, set_unread: "false"}, format: :json
end
it 'marks a notification as unread if it is told to' do
note = FactoryGirl.create(:notification)
- expect(Notification).to receive( :where ).and_return( [note] )
- expect(note).to receive( :set_read_state ).with( false )
- get :update, "id" => note.id, :set_unread => "true", :format => :json
+ expect(Notification).to receive(:where).and_return([note])
+ expect(note).to receive(:set_read_state).with(false)
+ get :update, params: {id: note.id, set_unread: "true"}, format: :json
end
it "marks a notification as unread without timestamping" do
@@ -34,7 +34,7 @@ describe NotificationsController, :type => :controller do
FactoryGirl.create(:notification, recipient: alice, unread: false)
end
- get :update, "id" => note.id, :set_unread => "true", :format => :json
+ get :update, params: {id: note.id, set_unread: "true"}, format: :json
expect(response).to be_success
updated_note = Notification.find(note.id)
@@ -48,7 +48,7 @@ describe NotificationsController, :type => :controller do
FactoryGirl.create(:notification, :recipient => alice)
note = FactoryGirl.create(:notification, :recipient => user2)
- get :update, "id" => note.id, :set_unread => "false", :format => :json
+ get :update, params: {id: note.id, set_unread: "false"}, format: :json
expect(Notification.find(note.id).unread).to eq(true)
end
@@ -90,7 +90,7 @@ describe NotificationsController, :type => :controller do
end
it 'succeeds on mobile' do
- get :index, :format => :mobile
+ get :index, format: :mobile
expect(response).to be_success
end
@@ -98,33 +98,33 @@ describe NotificationsController, :type => :controller do
25.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) }
get :index
expect(assigns[:notifications].count).to eq(25)
- get :index, "page" => 2
+ get :index, params: {page: 2}
expect(assigns[:notifications].count).to eq(1)
end
it "supports a limit per_page parameter" do
2.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) }
- get :index, "per_page" => 2
+ get :index, params: {per_page: 2}
expect(assigns[:notifications].count).to eq(2)
end
describe "special case for start sharing notifications" do
it "should not provide a contacts menu for standard notifications" do
FactoryGirl.create(:notification, :recipient => alice, :target => @post)
- get :index, "per_page" => 5
+ get :index, params: {per_page: 5}
expect(Nokogiri(response.body).css('.aspect_membership')).to be_empty
end
it "should provide a contacts menu for start sharing notifications" do
eve.share_with(alice.person, eve.aspects.first)
- get :index, "per_page" => 5
+ get :index, params: {per_page: 5}
expect(Nokogiri(response.body).css(".aspect_membership_dropdown")).not_to be_empty
end
it 'succeeds on mobile' do
eve.share_with(alice.person, eve.aspects.first)
- get :index, :format => :mobile
+ get :index, format: :mobile
expect(response).to be_success
end
end
@@ -132,7 +132,7 @@ describe NotificationsController, :type => :controller do
describe "filter notifications" do
it "supports filtering by notification type" do
FactoryGirl.create(:notification, :recipient => alice, :type => "Notifications::StartedSharing")
- get :index, "type" => "started_sharing"
+ get :index, params: {type: "started_sharing"}
expect(assigns[:notifications].count).to eq(1)
end
@@ -140,7 +140,7 @@ describe NotificationsController, :type => :controller do
FactoryGirl.create(:notification, :recipient => alice, :target => @post)
get :read_all
FactoryGirl.create(:notification, :recipient => alice, :target => @post)
- get :index, "show" => "unread"
+ get :index, params: {show: "unread"}
expect(assigns[:notifications].count).to eq(1)
end
end
@@ -165,46 +165,54 @@ describe NotificationsController, :type => :controller do
end
describe "#read_all" do
- it 'marks all notifications as read' do
- request.env["HTTP_REFERER"] = "I wish I were spelled right"
- FactoryGirl.create(:notification, :recipient => alice, :target => @post)
- FactoryGirl.create(:notification, :recipient => alice, :target => @post)
+ let(:post) { FactoryGirl.create(:status_message) }
- expect(Notification.where(:unread => true).count).to eq(2)
- get :read_all
- expect(Notification.where(:unread => true).count).to eq(0)
- end
- it 'marks all notifications in the current filter as read' do
+ it "marks all notifications as read" do
request.env["HTTP_REFERER"] = "I wish I were spelled right"
- FactoryGirl.create(:notification, :recipient => alice, :target => @post)
- FactoryGirl.create(:notification, :recipient => alice, :type => "Notifications::StartedSharing")
- expect(Notification.where(:unread => true).count).to eq(2)
- get :read_all, "type" => "started_sharing"
- expect(Notification.where(:unread => true).count).to eq(1)
+ FactoryGirl.create(:notification, recipient: alice, target: post)
+ FactoryGirl.create(:notification, recipient: alice, target: post)
+
+ expect(Notification.where(unread: true).count).to eq(2)
+ get :read_all
+ expect(Notification.where(unread: true).count).to eq(0)
end
+
+ it "marks all notifications in the current filter as read" do
+ request.env["HTTP_REFERER"] = "I wish I were spelled right"
+ FactoryGirl.create(:notification, recipient: alice, target: post)
+ FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing")
+ expect(Notification.where(unread: true).count).to eq(2)
+ get :read_all, params: {type: "started_sharing"}
+ expect(Notification.where(unread: true).count).to eq(1)
+ end
+
it "should redirect back in the html version if it has > 0 notifications" do
- FactoryGirl.create(:notification, :recipient => alice, :type => "Notifications::StartedSharing")
- get :read_all, :format => :html, "type" => "liked"
+ FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing")
+ get :read_all, params: {type: "liked"}, format: :html
expect(response).to redirect_to(notifications_path)
end
+
it "should redirect back in the mobile version if it has > 0 notifications" do
- FactoryGirl.create(:notification, :recipient => alice, :type => "Notifications::StartedSharing")
- get :read_all, :format => :mobile, "type" => "liked"
+ FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing")
+ get :read_all, params: {type: "liked"}, format: :mobile
expect(response).to redirect_to(notifications_path)
end
+
it "should redirect to stream in the html version if it has 0 notifications" do
- FactoryGirl.create(:notification, :recipient => alice, :type => "Notifications::StartedSharing")
- get :read_all, :format => :html, "type" => "started_sharing"
+ FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing")
+ get :read_all, params: {type: "started_sharing"}, format: :html
expect(response).to redirect_to(stream_path)
end
+
it "should redirect back in the mobile version if it has 0 notifications" do
- FactoryGirl.create(:notification, :recipient => alice, :type => "Notifications::StartedSharing")
- get :read_all, :format => :mobile, "type" => "started_sharing"
+ FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing")
+ get :read_all, params: {type: "started_sharing"}, format: :mobile
expect(response).to redirect_to(stream_path)
end
+
it "should return a dummy value in the json version" do
- FactoryGirl.create(:notification, :recipient => alice, :target => @post)
- get :read_all, :format => :json
+ FactoryGirl.create(:notification, recipient: alice, target: post)
+ get :read_all, format: :json
expect(response).not_to be_redirect
end
end
diff --git a/spec/controllers/participations_controller_spec.rb b/spec/controllers/participations_controller_spec.rb
index f557188f1..9c2fc1e2c 100644
--- a/spec/controllers/participations_controller_spec.rb
+++ b/spec/controllers/participations_controller_spec.rb
@@ -9,7 +9,7 @@ describe ParticipationsController, :type => :controller do
shared_examples 'on a visible post' do
it 'creates the participation' do
- post :create, post_id: @post.id
+ post :create, params: {post_id: @post.id}
expect(alice.participations.where(:target_id => @post.id)).to exist
expect(response.code).to eq('201')
end
@@ -47,7 +47,7 @@ describe ParticipationsController, :type => :controller do
end
it 'should not create the participation' do
- post :create, post_id: @post.id
+ post :create, params: {post_id: @post.id}
expect(alice.participations.where(:target_id => @post.id)).not_to exist
expect(response.code).to eq('403')
end
@@ -61,7 +61,7 @@ describe ParticipationsController, :type => :controller do
before { alice.participate! post }
it 'should remove participation' do
- delete :destroy, post_id: post.id
+ delete :destroy, params: {post_id: post.id}
expect(alice.participations.where(:target_id => post.id)).not_to exist
expect(response.code).to eq('200')
end
@@ -69,7 +69,7 @@ describe ParticipationsController, :type => :controller do
context 'on a post you do not partecipate to' do
it 'says it is an unprocessable request' do
- delete :destroy, post_id: post.id
+ delete :destroy, params: {post_id: post.id}
expect(response.code).to eq('422')
end
end
diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb
index 31c3d3e73..378e3a111 100644
--- a/spec/controllers/passwords_controller_spec.rb
+++ b/spec/controllers/passwords_controller_spec.rb
@@ -10,23 +10,23 @@ describe Devise::PasswordsController, type: :controller do
describe "#create" do
context "when there is no such user" do
it "succeeds" do
- post :create, "user" => {"email" => "foo@example.com"}
+ post :create, params: {user: {email: "foo@example.com"}}
expect(response).to be_success
end
it "doesn't send email" do
expect(Workers::ResetPassword).not_to receive(:perform_async)
- post :create, "user" => {"email" => "foo@example.com"}
+ post :create, params: {user: {email: "foo@example.com"}}
end
end
context "when there is a user with that email" do
it "redirects to the login page" do
- post :create, "user" => {"email" => alice.email}
+ post :create, params: {user: {email: alice.email}}
expect(response).to redirect_to(new_user_session_path)
end
it "sends email (enqueued to Sidekiq)" do
expect(Workers::ResetPassword).to receive(:perform_async).with(alice.id)
- post :create, "user" => {"email" => alice.email}
+ post :create, params: {user: {email: alice.email}}
end
end
end
diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb
index 846244927..bb450b88c 100644
--- a/spec/controllers/people_controller_spec.rb
+++ b/spec/controllers/people_controller_spec.rb
@@ -30,24 +30,24 @@ describe PeopleController, :type => :controller do
describe 'via json' do
it 'succeeds' do
- get :index, :q => "Korth", :format => 'json'
+ get :index, params: {q: "Korth"}, format: :json
expect(response).to be_success
end
it 'responds with json' do
- get :index, :q => "Korth", :format => 'json'
+ get :index, params: {q: "Korth"}, format: :json
expect(response.body).to eq([@korth].to_json)
end
it 'does not assign hashes' do
- get :index, :q => "Korth", :format => 'json'
+ get :index, params: {q: "Korth"}, format: :json
expect(assigns[:hashes]).to be_nil
end
it "doesn't include closed accounts" do
- get :index, q: "Closed", format: "json"
+ get :index, params: {q: "Closed"}, format: :json
expect(JSON.parse(response.body).size).to eq(0)
- get :index, q: @closed.diaspora_handle, format: "json"
+ get :index, params: {q: @closed.diaspora_handle}, format: :json
expect(JSON.parse(response.body).size).to eq(0)
end
end
@@ -60,39 +60,39 @@ describe PeopleController, :type => :controller do
:last_name => "w", :searchable => false))
end
it 'finds people even if they have searchable off' do
- get :index, :q => "eugene@example.org"
+ get :index, params: {q: "eugene@example.org"}
expect(assigns[:people][0].id).to eq(@unsearchable_eugene.id)
end
it 'downcases the query term' do
- get :index, :q => "Eugene@Example.ORG"
+ get :index, params: {q: "Eugene@Example.ORG"}
expect(assigns[:people][0].id).to eq(@unsearchable_eugene.id)
end
it 'does not the background query task if the user is found' do
- get :index, :q => "Eugene@Example.ORG"
+ get :index, params: {q: "Eugene@Example.ORG"}
expect(assigns[:background_query]).to eq(nil)
end
it 'sets background query task if the user is not found' do
- get :index, :q => "Eugene@Example1.ORG"
+ get :index, params: {q: "Eugene@Example1.ORG"}
expect(assigns[:background_query]).to eq("eugene@example1.org")
end
it "doesn't include closed accounts" do
- get :index, q: @closed.diaspora_handle
+ get :index, params: {q: @closed.diaspora_handle}
expect(assigns[:people].size).to eq(0)
end
end
context 'query is not a tag or a diaspora ID' do
it 'assigns hashes' do
- get :index, :q => "Korth"
+ get :index, params: {q: "Korth"}
expect(assigns[:hashes]).not_to be_nil
end
it 'does not set the background query task' do
- get :index, :q => "Korth"
+ get :index, params: {q: "Korth"}
expect(assigns[:background_query]).not_to be_present
end
@@ -100,29 +100,29 @@ describe PeopleController, :type => :controller do
eugene2 = FactoryGirl.create(:person,
:profile => FactoryGirl.build(:profile, :first_name => "Eugene",
:last_name => "w"))
- get :index, :q => "Eug"
+ get :index, params: {q: "Eug"}
expect(assigns[:people].map { |x| x.id }).to match_array([@eugene.id, eugene2.id])
end
it "succeeds if there is exactly one match" do
- get :index, :q => "Korth"
+ get :index, params: {q: "Korth"}
expect(assigns[:people].length).to eq(1)
expect(response).to be_success
end
it "succeeds if there are no matches" do
- get :index, :q => "Korthsauce"
+ get :index, params: {q: "Korthsauce"}
expect(assigns[:people].length).to eq(0)
expect(response).to be_success
end
it 'succeeds if you search for the empty term' do
- get :index, :q => ''
+ get :index, params: {q: ""}
expect(response).to be_success
end
it 'succeeds if you search for punctuation' do
- get :index, :q => '+'
+ get :index, params: {q: "+"}
expect(response).to be_success
end
@@ -130,12 +130,12 @@ describe PeopleController, :type => :controller do
eugene2 = FactoryGirl.create(:person,
:profile => FactoryGirl.build(:profile, :first_name => "Eugene",
:last_name => "w", :searchable => false))
- get :index, :q => "Eug"
+ get :index, params: {q: "Eug"}
expect(assigns[:people]).not_to match_array([eugene2])
end
it "doesn't include closed accounts" do
- get :index, q: "Closed"
+ get :index, params: {q: "Closed"}
expect(assigns[:people].size).to eq(0)
end
end
@@ -164,7 +164,7 @@ describe PeopleController, :type => :controller do
it 'takes time' do
expect(Benchmark.realtime {
- get :show, :id => @user.person.to_param
+ get :show, params: {id: @user.person.to_param}
}).to be < 1.0
end
end
@@ -176,44 +176,44 @@ describe PeopleController, :type => :controller do
end
it "404s if the id is invalid" do
- get :show, :id => 'delicious'
+ get :show, params: {id: "delicious"}
expect(response.code).to eq("404")
end
it "404s if no person is found via id" do
- get :show, :id => "3d920397846"
+ get :show, params: {id: "3d920397846"}
expect(response.code).to eq("404")
end
it "404s if no person is found via username" do
- get :show, :username => 'delicious'
+ get :show, params: {username: "delicious"}
expect(response.code).to eq("404")
end
it "returns a person presenter" do
expect(PersonPresenter).to receive(:new).with(@person, @user).and_return(@presenter)
- get :show, username: @person.username
+ get :show, params: {username: @person.username}
expect(assigns(:presenter).to_json).to eq(@presenter.to_json)
end
it 'finds a person via username' do
- get :show, username: @person.username
+ get :show, params: {username: @person.username}
expect(assigns(:presenter).to_json).to eq(@presenter.to_json)
end
it "404s if no person is found via diaspora handle" do
- get :show, :username => 'delicious@pod.net'
+ get :show, params: {username: "delicious@pod.net"}
expect(response.code).to eq("404")
end
it 'finds a person via diaspora handle' do
- get :show, username: @person.diaspora_handle
+ get :show, params: {username: @person.diaspora_handle}
expect(assigns(:presenter).to_json).to eq(@presenter.to_json)
end
it 'redirects home for closed account' do
@person = FactoryGirl.create(:person, :closed_account => true)
- get :show, :id => @person.to_param
+ get :show, params: {id: @person.to_param}
expect(response).to be_redirect
expect(flash[:notice]).not_to be_blank
end
@@ -222,7 +222,7 @@ describe PeopleController, :type => :controller do
user2 = bob
profile = user2.profile
profile.update_attribute(:first_name, "")
- get :show, :id => user2.person.to_param
+ get :show, params: {id: user2.person.to_param}
expect(response).to be_success
expect(response.body).not_to include(profile.first_name)
end
@@ -231,27 +231,27 @@ describe PeopleController, :type => :controller do
16.times do |i|
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true)
end
- get :show, :id => eve.person.to_param
+ get :show, params: {id: eve.person.to_param}
expect(response.body).to include ',"photos_count":16'
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => false)
- get :show, :id => eve.person.to_param
+ get :show, params: {id: eve.person.to_param}
expect(response.body).to include ',"photos_count":16' # eve is not sharing with alice
end
context "when the person is the current user" do
it "succeeds" do
- get :show, :id => @user.person.to_param
+ get :show, params: {id: @user.person.to_param}
expect(response).to be_success
end
it 'succeeds on the mobile site' do
- get :show, :id => @user.person.to_param, :format => :mobile
+ get :show, params: {id: @user.person.to_param}, format: :mobile
expect(response).to be_success
end
it "assigns the right person" do
- get :show, id: @person.to_param
+ get :show, params: {id: @person.to_param}
expect(assigns(:presenter).id).to eq(@presenter.id)
end
end
@@ -263,25 +263,25 @@ describe PeopleController, :type => :controller do
end
it "succeeds" do
- get :show, :id => @person.to_param
+ get :show, params: {id: @person.to_param}
expect(response.status).to eq(200)
end
it 'succeeds on the mobile site' do
- get :show, :id => @person.to_param, :format => :mobile
+ get :show, params: {id: @person.to_param}, format: :mobile
expect(response).to be_success
end
it 'forces to sign in if the person is remote' do
p = FactoryGirl.create(:person)
- get :show, :id => p.to_param
+ get :show, params: {id: p.to_param}
expect(response).to be_redirect
expect(response).to redirect_to new_user_session_path
end
it "leaks no private profile info" do
- get :show, id: @person.to_param
+ get :show, params: {id: @person.to_param}
expect(response.body).not_to include(@person.profile.bio)
end
@@ -296,7 +296,7 @@ describe PeopleController, :type => :controller do
last_name: {html_attribute: "property", name: "og:profile:last_name"}
}
- get :show, id: @person.to_param
+ get :show, params: {id: @person.to_param}
methods_properties.each do |method, property|
value = presenter.send(method)
@@ -313,12 +313,12 @@ describe PeopleController, :type => :controller do
end
it "succeeds" do
- get :show, :id => @person.to_param
+ get :show, params: {id: @person.to_param}
expect(response).to be_success
end
it 'succeeds on the mobile site' do
- get :show, :id => @person.to_param, :format => :mobile
+ get :show, params: {id: @person.to_param}, format: :mobile
expect(response).to be_success
end
@@ -326,18 +326,18 @@ describe PeopleController, :type => :controller do
note = FactoryGirl.create(:notification, :recipient => @user, :target => @person, :unread => true)
expect {
- get :show, :id => @person.to_param
+ get :show, params: {id: @person.to_param}
note.reload
}.to change(Notification.where(:unread => true), :count).by(-1)
end
it "includes private profile info" do
- get :show, id: @person.to_param
+ get :show, params: {id: @person.to_param}
expect(response.body).to include(@person.profile.bio)
end
it "preloads data using gon for the aspect memberships dropdown" do
- get :show, id: @person.to_param
+ get :show, params: {id: @person.to_param}
expect_gon_preloads_for_aspect_membership_dropdown(:person, true)
end
end
@@ -348,22 +348,22 @@ describe PeopleController, :type => :controller do
end
it "succeeds" do
- get :show, :id => @person.to_param
+ get :show, params: {id: @person.to_param}
expect(response).to be_success
end
it 'succeeds on the mobile site' do
- get :show, :id => @person.to_param, :format => :mobile
+ get :show, params: {id: @person.to_param}, format: :mobile
expect(response).to be_success
end
it "leaks no private profile info" do
- get :show, id: @person.to_param
+ get :show, params: {id: @person.to_param}
expect(response.body).not_to include(@person.profile.bio)
end
it "preloads data using gon for the aspect memberships dropdown" do
- get :show, id: @person.to_param
+ get :show, params: {id: @person.to_param}
expect_gon_preloads_for_aspect_membership_dropdown(:person, false)
end
end
@@ -376,7 +376,7 @@ describe PeopleController, :type => :controller do
end
it "leaks no private profile info" do
- get :show, id: @person.to_param
+ get :show, params: {id: @person.to_param}
expect(response.body).not_to include(@person.profile.bio)
end
end
@@ -384,7 +384,7 @@ describe PeopleController, :type => :controller do
describe '#stream' do
it "redirects non-json requests" do
- get :stream, person_id: @user.person.to_param
+ get :stream, params: {person_id: @user.person.to_param}
expect(response).to be_redirect
end
@@ -395,7 +395,7 @@ describe PeopleController, :type => :controller do
@user.post(:status_message, :text => "to all aspects", :to => 'all')
@user.post(:status_message, :text => "public", :to => 'all', :public => true)
expect(@user.reload.posts.length).to eq(3)
- get :stream, person_id: @user.person.to_param, format: :json
+ get :stream, params: {person_id: @user.person.to_param}, format: :json
expect(assigns(:stream).posts.map(&:id)).to match_array(@user.posts.map(&:id))
end
@@ -403,7 +403,7 @@ describe PeopleController, :type => :controller do
cmmt = 'I mean it'
message = @user.post :status_message, :text => 'test more', :to => @aspect.id
@user.comment!(message, cmmt)
- get :stream, person_id: @user.person.to_param, format: :json
+ get :stream, params: {person_id: @user.person.to_param}, format: :json
expect(response).to be_success
expect(response.body).to include(cmmt)
end
@@ -416,7 +416,7 @@ describe PeopleController, :type => :controller do
it "includes reshares" do
reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspect_ids)
- get :stream, person_id: @user.person.to_param, format: :json
+ get :stream, params: {person_id: @user.person.to_param}, format: :json
expect(assigns[:stream].posts.map { |x| x.id }).to include(reshare.id)
end
@@ -431,7 +431,7 @@ describe PeopleController, :type => :controller do
posts_user_can_see << bob.post(:status_message, :text => "public", :to => 'all', :public => true)
expect(bob.reload.posts.length).to eq(4)
- get :stream, person_id: @person.to_param, format: :json
+ get :stream, params: {person_id: @person.to_param}, format: :json
expect(assigns(:stream).posts.map(&:id)).to match_array(posts_user_can_see.map(&:id))
end
end
@@ -448,13 +448,13 @@ describe PeopleController, :type => :controller do
public_post = eve.post(:status_message, :text => "public", :to => 'all', :public => true)
expect(eve.reload.posts.length).to eq(3)
- get :stream, person_id: @person.to_param, format: :json
+ get :stream, params: {person_id: @person.to_param}, format: :json
expect(assigns[:stream].posts.map(&:id)).to match_array([public_post].map(&:id))
end
it "posts include reshares" do
reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspect_ids)
- get :stream, person_id: @user.person.to_param, format: :json
+ get :stream, params: {person_id: @user.person.to_param}, format: :json
expect(assigns[:stream].posts.map { |x| x.id }).to include(reshare.id)
end
end
@@ -478,17 +478,17 @@ describe PeopleController, :type => :controller do
it "posts include reshares" do
reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspect_ids)
- get :stream, person_id: @user.person.to_param, format: :json
+ get :stream, params: {person_id: @user.person.to_param}, format: :json
expect(assigns[:stream].posts.map { |x| x.id }).to include(reshare.id)
end
it "assigns only public posts" do
- get :stream, person_id: @person.to_param, format: :json
+ get :stream, params: {person_id: @person.to_param}, format: :json
expect(assigns[:stream].posts.map(&:id)).to match_array(@public_posts.map(&:id))
end
it 'is sorted by created_at desc' do
- get :stream, person_id: @person.to_param, format: :json
+ get :stream, params: {person_id: @person.to_param}, format: :json
expect(assigns[:stream].stream_posts).to eq(@public_posts.sort_by { |p| p.created_at }.reverse)
end
end
@@ -503,19 +503,19 @@ describe PeopleController, :type => :controller do
end
it 'redirects html requests' do
- get :hovercard, :person_id => @hover_test.guid
+ get :hovercard, params: {person_id: @hover_test.guid}
expect(response).to redirect_to person_path(:id => @hover_test.guid)
end
it 'returns json with profile stuff' do
- get :hovercard, :person_id => @hover_test.guid, :format => 'json'
+ get :hovercard, params: {person_id: @hover_test.guid}, format: :json
expect(JSON.parse(response.body)["diaspora_id"]).to eq(@hover_test.diaspora_handle)
end
it "returns contact when sharing" do
alice.share_with(@hover_test, alice.aspects.first)
expect(@controller).to receive(:current_user).at_least(:once).and_return(alice)
- get :hovercard, person_id: @hover_test.guid, format: "json"
+ get :hovercard, params: {person_id: @hover_test.guid}, format: :json
expect(JSON.parse(response.body)["contact"]).not_to be_falsy
end
@@ -525,13 +525,13 @@ describe PeopleController, :type => :controller do
end
it "succeeds with local person" do
- get :hovercard, person_id: bob.person.guid, format: :json
+ get :hovercard, params: {person_id: bob.person.guid}, format: :json
expect(response.status).to eq(200)
expect(JSON.parse(response.body)["diaspora_id"]).to eq(bob.diaspora_handle)
end
it "succeeds with remote person" do
- get :hovercard, person_id: remote_raphael.guid, format: :json
+ get :hovercard, params: {person_id: remote_raphael.guid}, format: :json
expect(response.status).to eq(200)
expect(JSON.parse(response.body)["diaspora_id"]).to eq(remote_raphael.diaspora_handle)
end
@@ -557,22 +557,22 @@ describe PeopleController, :type => :controller do
describe "via json" do
it "returns no data when a search fails" do
- get :refresh_search, q: "weweweKorth", format: "json"
+ get :refresh_search, params: {q: "weweweKorth"}, format: :json
expect(response.body).to eq({search_html: "", contacts: nil}.to_json)
end
it "returns no data unless a fully composed name is sent" do
- get :refresh_search, q: "Korth"
+ get :refresh_search, params: {q: "Korth"}
expect(response.body).to eq({search_html: "", contacts: nil}.to_json)
end
it "returns with a found name" do
- get :refresh_search, q: @korth.diaspora_handle
+ get :refresh_search, params: {q: @korth.diaspora_handle}
expect(JSON.parse(response.body)["contacts"].size).to eq(1)
end
it "doesn't include closed accounts" do
- get :refresh_search, q: @closed.diaspora_handle
+ get :refresh_search, params: {q: @closed.diaspora_handle}
expect(JSON.parse(response.body)["contacts"]).to be_nil
end
end
@@ -583,13 +583,13 @@ describe PeopleController, :type => :controller do
it 'assigns the contacts of a person' do
contact = alice.contact_for(bob.person)
contacts = contact.contacts
- get :contacts, :person_id => bob.person.to_param
+ get :contacts, params: {person_id: bob.person.to_param}
expect(assigns(:contacts_of_contact).to_a).to eq(contacts.to_a)
expect(response).to be_success
end
it 'shows an error when invalid person id' do
- get :contacts, :person_id => 'foo'
+ get :contacts, params: {person_id: "foo"}
expect(flash[:error]).to be_present
expect(response).to redirect_to people_path
end
@@ -598,16 +598,16 @@ describe PeopleController, :type => :controller do
16.times do |i|
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true)
end
- get :contacts, :person_id => eve.person.to_param
+ get :contacts, params: {person_id: eve.person.to_param}
expect(response.body).to include ',"photos_count":16'
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => false)
- get :contacts, :person_id => eve.person.to_param
+ get :contacts, params: {person_id: eve.person.to_param}
expect(response.body).to include ',"photos_count":16' # eve is not sharing with alice
end
it "returns a 406 for json format" do
- get :contacts, person_id: "foo", format: :json
+ get :contacts, params: {person_id: "foo"}, format: :json
expect(response.code).to eq("406")
end
end
diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb
index 9b76fffe5..d323ba87b 100644
--- a/spec/controllers/photos_controller_spec.rb
+++ b/spec/controllers/photos_controller_spec.rb
@@ -24,18 +24,18 @@ describe PhotosController, :type => :controller do
it 'accepts a photo from a regular form submission' do
expect {
- post :create, @params
+ post :create, params: @params
}.to change(Photo, :count).by(1)
end
it 'returns application/json when possible' do
request.env['HTTP_ACCEPT'] = 'application/json'
- expect(post(:create, @params).headers['Content-Type']).to match 'application/json.*'
+ expect(post(:create, params: @params).headers["Content-Type"]).to match "application/json.*"
end
it 'returns text/html by default' do
request.env['HTTP_ACCEPT'] = 'text/html,*/*'
- expect(post(:create, @params).headers['Content-Type']).to match 'text/html.*'
+ expect(post(:create, params: @params).headers["Content-Type"]).to match "text/html.*"
end
end
@@ -47,57 +47,57 @@ describe PhotosController, :type => :controller do
it "creates a photo" do
expect {
- post :create, @params
+ post :create, params: @params
}.to change(Photo, :count).by(1)
end
it "doesn't allow mass assignment of person" do
new_user = FactoryGirl.create(:user)
@params[:photo][:author] = new_user
- post :create, @params
+ post :create, params: @params
expect(Photo.last.author).to eq(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
+ post :create, params: @params
expect(Photo.last.author).to eq(alice.person)
end
it 'can set the photo as the profile photo' do
old_url = alice.person.profile.image_url
@params[:photo][:set_profile_photo] = true
- post :create, @params
+ post :create, params: @params
expect(alice.reload.person.profile.image_url).not_to eq(old_url)
end
end
describe '#index' do
it "succeeds without any available pictures" do
- get :index, :person_id => FactoryGirl.create(:person).guid.to_s
+ get :index, params: {person_id: FactoryGirl.create(:person).guid}
expect(response).to be_success
end
it "succeeds on mobile devices without any available pictures" do
- get :index, format: :mobile, person_id: FactoryGirl.create(:person).guid.to_s
+ get :index, params: {person_id: FactoryGirl.create(:person).guid}, format: :mobile
expect(response).to be_success
end
it "succeeds on mobile devices with available pictures" do
- get :index, format: :mobile, person_id: bob.person.guid.to_s
+ get :index, params: {person_id: bob.person.guid}, format: :mobile
expect(response).to be_success
end
it "displays the logged in user's pictures" do
- get :index, :person_id => alice.person.guid.to_s
+ get :index, params: {person_id: alice.person.guid}
expect(assigns[:person]).to eq(alice.person)
expect(assigns[:posts]).to eq([@alices_photo])
end
it "displays another person's pictures" do
- get :index, :person_id => bob.person.guid.to_s
+ get :index, params: {person_id: bob.person.guid}
expect(assigns[:person]).to eq(bob.person)
expect(assigns[:posts]).to eq([@bobs_photo])
end
@@ -106,25 +106,24 @@ describe PhotosController, :type => :controller do
16.times do |i|
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true)
end
- get :index, :person_id => eve.person.to_param
+ get :index, params: {person_id: eve.person.to_param}
expect(response.body).to include ',"photos_count":16'
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => false)
- get :index, :person_id => eve.person.to_param
+ get :index, params: {person_id: eve.person.to_param}
expect(response.body).to include ',"photos_count":16' # eve is not sharing with alice
end
it "returns json when requested" do
request.env['HTTP_ACCEPT'] = 'application/json'
- get :index, :person_id => alice.person.guid.to_s
+ get :index, params: {person_id: alice.person.guid}
expect(response.headers['Content-Type']).to match 'application/json.*'
end
it 'displays by date of creation' do
max_time = bob.photos.first.created_at - 1.day
- get :index, person_id: bob.person.guid.to_s,
- max_time: max_time.to_i
+ get :index, params: {person_id: bob.person.guid, max_time: max_time.to_i}
expect(assigns[:posts]).to be_empty
end
@@ -136,19 +135,19 @@ describe PhotosController, :type => :controller do
end
it "succeeds" do
- get :index, person_id: @person.to_param
+ get :index, params: {person_id: @person.to_param}
expect(response.status).to eq(200)
end
it "succeeds on the mobile site" do
- get :index, person_id: @person.to_param, format: :mobile
+ get :index, params: {person_id: @person.to_param}, format: :mobile
expect(response).to be_success
end
it "forces to sign in if the person is remote" do
p = FactoryGirl.create(:person)
- get :index, person_id: p.to_param
+ get :index, params: {person_id: p.to_param}
expect(response).to be_redirect
expect(response).to redirect_to new_user_session_path
end
@@ -157,16 +156,16 @@ describe PhotosController, :type => :controller do
16.times do
eve.post(:photo, user_file: uploaded_photo, to: eve.aspects.first.id, public: true)
end
- get :index, person_id: eve.person.to_param
+ get :index, params: {person_id: eve.person.to_param}
expect(response.body).to include ',"photos_count":16'
eve.post(:photo, user_file: uploaded_photo, to: eve.aspects.first.id, public: false)
- get :index, person_id: eve.person.to_param
+ get :index, params: {person_id: eve.person.to_param}
expect(response.body).to include ',"photos_count":16'
end
it "displays a person's pictures" do
- get :index, person_id: bob.person.guid.to_s
+ get :index, params: {person_id: bob.person.guid}
expect(assigns[:person]).to eq(bob.person)
expect(assigns[:posts]).to eq([@bobs_photo])
end
@@ -175,42 +174,42 @@ describe PhotosController, :type => :controller do
describe '#destroy' do
it 'let a user delete his message' do
- delete :destroy, :id => @alices_photo.id
+ delete :destroy, params: {id: @alices_photo.id}
expect(Photo.find_by_id(@alices_photo.id)).to be_nil
end
it 'will let you delete your profile picture' do
- xhr :get, :make_profile_photo, :photo_id => @alices_photo.id, :format => :js
- delete :destroy, :id => @alices_photo.id
+ get :make_profile_photo, params: {photo_id: @alices_photo.id}, xhr: true, format: :js
+ delete :destroy, params: {id: @alices_photo.id}, format: :json
expect(Photo.find_by_id(@alices_photo.id)).to be_nil
end
it 'sends a retraction on delete' do
allow(@controller).to receive(:current_user).and_return(alice)
expect(alice).to receive(:retract).with(@alices_photo)
- delete :destroy, :id => @alices_photo.id
+ delete :destroy, params: {id: @alices_photo.id}
end
it 'will not let you destroy posts visible to you' do
- delete :destroy, :id => @bobs_photo.id
+ delete :destroy, params: {id: @bobs_photo.id}
expect(Photo.find_by_id(@bobs_photo.id)).to be_truthy
end
it 'will not let you destroy posts you do not own' do
eves_photo = eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true)
- delete :destroy, :id => eves_photo.id
+ delete :destroy, params: {id: eves_photo.id}
expect(Photo.find_by_id(eves_photo.id)).to be_truthy
end
end
describe "#make_profile_photo" do
it 'should return a 201 on a js success' do
- xhr :get, :make_profile_photo, :photo_id => @alices_photo.id, :format => 'js'
+ get :make_profile_photo, params: {photo_id: @alices_photo.id}, xhr: true, format: :js
expect(response.code).to eq("201")
end
it 'should return a 422 on failure' do
- get :make_profile_photo, :photo_id => @bobs_photo.id
+ get :make_profile_photo, params: {photo_id: @bobs_photo.id}
expect(response.code).to eq("422")
end
end
@@ -218,19 +217,19 @@ describe PhotosController, :type => :controller do
describe "#show" do
it 'should return 404 for nonexistent stuff on mobile devices' do
expect {
- get :show, :person_id => bob.person.guid, :id => 772831, :format => 'mobile'
+ get :show, params: {person_id: bob.person.guid, id: 772_831}, format: :mobile
}.to raise_error ActiveRecord::RecordNotFound
end
it 'should return 200 for existing stuff on mobile devices' do
- get :show, :person_id => alice.person.guid, :id => @alices_photo.id, :format => 'mobile'
+ get :show, params: {person_id: alice.person.guid, id: @alices_photo.id}, format: :mobile
expect(response).to be_success
end
it "doesn't leak private photos to the public" do
sign_out :user
expect {
- get :show, :person_id => alice.person.guid, :id => @alices_photo.id, :format => 'mobile'
+ get :show, params: {person_id: alice.person.guid, id: @alices_photo.id}, format: :mobile
}.to raise_error ActiveRecord::RecordNotFound
end
end
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
index efbc1d8dd..28216a97e 100644
--- a/spec/controllers/posts_controller_spec.rb
+++ b/spec/controllers/posts_controller_spec.rb
@@ -16,7 +16,7 @@ describe PostsController, type: :controller do
it "succeeds" do
expect_any_instance_of(PostService).to receive(:mark_user_notifications).with(post.id)
- get :show, id: post.id
+ get :show, params: {id: post.id}
expect(response).to be_success
end
@@ -29,12 +29,12 @@ describe PostsController, type: :controller do
expect(msg.mentioned_people.count).to eq(1)
user.destroy
- get :show, id: msg.id
+ get :show, params: {id: msg.id}
expect(response).to be_success
end
it "renders the application layout on mobile" do
- get :show, id: post.id, format: :mobile
+ get :show, params: {id: post.id}, format: :mobile
expect(response).to render_template("layouts/application")
end
@@ -42,7 +42,7 @@ describe PostsController, type: :controller do
reshare_id = FactoryGirl.create(:reshare, author: alice.person).id
expect_any_instance_of(PostService).to receive(:mark_user_notifications).with(reshare_id)
- get :show, id: reshare_id, format: :mobile
+ get :show, params: {id: reshare_id}, format: :mobile
expect(response).to be_success
end
end
@@ -54,7 +54,7 @@ describe PostsController, type: :controller do
it "returns a 404" do
expect {
- get :show, id: post.id
+ get :show, params: {id: post.id}
}.to raise_error ActiveRecord::RecordNotFound
end
end
@@ -66,13 +66,13 @@ describe PostsController, type: :controller do
let(:public_with_tags) { alice.post(:status_message, text: "#hi #howareyou", public: true) }
it "shows a public post" do
- get :show, id: public.id
+ get :show, params: {id: public.id}
expect(response.body).to match "hello"
end
it "succeeds for statusnet" do
@request.env["HTTP_ACCEPT"] = "application/html+xml,text/html"
- get :show, id: public.id
+ get :show, params: {id: public.id}
expect(response.body).to match "hello"
end
@@ -88,7 +88,7 @@ describe PostsController, type: :controller do
author_name: {html_attribute: "property", name: "og:article:author"}
}
- get :show, id: public.id, format: :html
+ get :show, params: {id: public.id}, format: :html
methods_properties.each do |method, property|
value = presenter.send(method)
@@ -99,7 +99,7 @@ describe PostsController, type: :controller do
end
it "includes the correct multiple meta tags" do
- get :show, id: public_with_tags.id, format: :html
+ get :show, params: {id: public_with_tags.id}, format: :html
expect(response.body).to include('')
expect(response.body).to include('')
@@ -108,7 +108,7 @@ describe PostsController, type: :controller do
context "given a limited post" do
it "forces the user to sign" do
- get :show, id: post.id
+ get :show, params: {id: post.id}
expect(response).to be_redirect
expect(response).to redirect_to new_user_session_path
end
@@ -119,12 +119,12 @@ describe PostsController, type: :controller do
describe "oembed" do
it "works when you can see it" do
sign_in alice
- get :oembed, url: "/posts/#{post.id}"
+ get :oembed, params: {url: "/posts/#{post.id}"}
expect(response.body).to match /iframe/
end
it "returns a 404 response when the post is not found" do
- get :oembed, url: "/posts/#{post.id}"
+ get :oembed, params: {url: "/posts/#{post.id}"}
expect(response.status).to eq(404)
end
end
@@ -132,13 +132,13 @@ describe PostsController, type: :controller do
describe "#interactions" do
context "user not signed in" do
it "returns a 401 for private posts and format json" do
- get :interactions, id: post.id, format: :json
+ get :interactions, params: {id: post.id}, format: :json
expect(response.status).to eq(401)
expect(JSON.parse(response.body)["error"]).to eq(I18n.t("devise.failure.unauthenticated"))
end
it "returns a 406 for private posts and format html" do
- get :interactions, id: post.id
+ get :interactions, params: {id: post.id}
expect(response.status).to eq(406)
end
end
@@ -149,13 +149,13 @@ describe PostsController, type: :controller do
end
it "shows interactions of a post as json" do
- get :interactions, id: post.id, format: :json
+ get :interactions, params: {id: post.id}, format: :json
expect(response.body).to eq(PostInteractionPresenter.new(post, alice).to_json)
end
it "returns a 406 for format html" do
sign_in alice
- get :interactions, id: post.id
+ get :interactions, params: {id: post.id}
expect(response.status).to eq(406)
end
end
@@ -168,12 +168,12 @@ describe PostsController, type: :controller do
end
it "returns status 204 without a :q parameter" do
- get :mentionable, id: post.id, format: :json
+ get :mentionable, params: {id: post.id}, format: :json
expect(response.status).to eq(204)
end
it "responses status 406 (not acceptable) on html request" do
- get :mentionable, id: post.id, q: "whatever", format: :html
+ get :mentionable, params: {id: post.id, q: "whatever"}, format: :html
expect(response.status).to eq(406)
end
@@ -181,13 +181,13 @@ describe PostsController, type: :controller do
expect(post_service).to receive(:find!) do
raise ActiveRecord::RecordNotFound
end
- get :mentionable, id: post.id, q: "whatever", format: :json
+ get :mentionable, params: {id: post.id, q: "whatever"}, format: :json
expect(response.status).to eq(404)
end
it "calls PostService#mentionable_in_comment and passes the result as a response" do
expect(post_service).to receive(:mentionable_in_comment).with(post.id.to_s, "whatever").and_return([bob.person])
- get :mentionable, id: post.id, q: "whatever", format: :json
+ get :mentionable, params: {id: post.id, q: "whatever"}, format: :json
expect(response.status).to eq(200)
expect(response.body).to eq([bob.person].to_json)
end
@@ -196,7 +196,7 @@ describe PostsController, type: :controller do
context "without a user signed in" do
it "returns 401" do
allow(post_service).to receive(:mentionable_in_comment).and_return([])
- get :mentionable, id: post.id, q: "whatever", format: :json
+ get :mentionable, params: {id: post.id, q: "whatever"}, format: :json
expect(response.status).to eq(401)
expect(JSON.parse(response.body)["error"]).to eq(I18n.t("devise.failure.unauthenticated"))
end
@@ -212,12 +212,12 @@ describe PostsController, type: :controller do
it "works when it is your post" do
expect_any_instance_of(PostService).to receive(:destroy).with(post.id.to_s)
- delete :destroy, format: :json, id: post.id
+ delete :destroy, params: {id: post.id}, format: :json
expect(response.status).to eq(204)
end
it "redirects to stream on mobile" do
- delete :destroy, format: :mobile, id: post.id
+ delete :destroy, params: {id: post.id}, format: :mobile
expect(response).to be_redirect
expect(response).to redirect_to stream_path
end
@@ -227,7 +227,7 @@ describe PostsController, type: :controller do
it "will respond with a 403" do
sign_in bob, scope: :user
- delete :destroy, format: :json, id: post.id
+ delete :destroy, params: {id: post.id}, format: :json
expect(response.body).to eq("You are not allowed to do that")
expect(response.status).to eq(403)
end
@@ -236,7 +236,7 @@ describe PostsController, type: :controller do
sign_in eve, scope: :user
expect {
- delete :destroy, format: :json, id: post.id
+ delete :destroy, params: {id: post.id}, format: :json
}.to raise_error ActiveRecord::RecordNotFound
end
end
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
index 9a6a47e8e..405b2902b 100644
--- a/spec/controllers/profiles_controller_spec.rb
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -15,7 +15,7 @@ describe ProfilesController, :type => :controller do
expect(Person).to receive(:find_by_guid!).with("12345").and_return(mock_person)
expect(PersonPresenter).to receive(:new).with(mock_person, eve).and_return(mock_presenter)
- get :show, :id => 12345, :format => :json
+ get :show, params: {id: 12_345}, format: :json
expect(response.body).to eq({:rock_star => "Jamie Cai"}.to_json)
end
end
@@ -44,27 +44,29 @@ describe ProfilesController, :type => :controller do
describe '#update' do
it "sets the flash" do
- put :update, :profile => {
- :image_url => "",
- :first_name => "Will",
- :last_name => "Smith"
+ put :update, params: {
+ profile: {
+ image_url: "",
+ first_name: "Will",
+ last_name: "Smith"
}
+ }
expect(flash[:notice]).not_to be_blank
end
it "sets nsfw" do
- expect(eve.person(true).profile.nsfw).to eq(false)
- put :update, :profile => { :id => eve.person.id, :nsfw => "1" }
- expect(eve.person(true).profile.nsfw).to eq(true)
+ expect(eve.person.reload.profile.nsfw).to eq(false)
+ put :update, params: {profile: {id: eve.person.id, nsfw: "1"}}
+ expect(eve.person.reload.profile.nsfw).to eq(true)
end
it "unsets nsfw" do
eve.person.profile.nsfw = true
eve.person.profile.save
- expect(eve.person(true).profile.nsfw).to eq(true)
- put :update, :profile => { :id => eve.person.id }
- expect(eve.person(true).profile.nsfw).to eq(false)
+ expect(eve.person.reload.profile.nsfw).to eq(true)
+ put :update, params: {profile: {id: eve.person.id}}
+ expect(eve.person.reload.profile.nsfw).to eq(false)
end
it 'sets tags' do
@@ -72,8 +74,8 @@ describe ProfilesController, :type => :controller do
:tags => '#apples #oranges',
:profile => {:tag_string => ''} }
- put :update, params
- expect(eve.person(true).profile.tag_list.to_set).to eq(['apples', 'oranges'].to_set)
+ put :update, params: params
+ expect(eve.person.reload.profile.tag_list.to_set).to eq(%w[apples oranges].to_set)
end
it 'sets plaintext tags' do
@@ -81,8 +83,8 @@ describe ProfilesController, :type => :controller do
:tags => ',#apples,#oranges,',
:profile => {:tag_string => '#pears'} }
- put :update, params
- expect(eve.person(true).profile.tag_list.to_set).to eq(['apples', 'oranges', 'pears'].to_set)
+ put :update, params: params
+ expect(eve.person.reload.profile.tag_list.to_set).to eq(%w[apples oranges pears].to_set)
end
it 'sets plaintext tags without #' do
@@ -90,8 +92,8 @@ describe ProfilesController, :type => :controller do
:tags => ',#apples,#oranges,',
:profile => {:tag_string => 'bananas'} }
- put :update, params
- expect(eve.person(true).profile.tag_list.to_set).to eq(['apples', 'oranges', 'bananas'].to_set)
+ put :update, params: params
+ expect(eve.person.reload.profile.tag_list.to_set).to eq(%w[apples oranges bananas].to_set)
end
it 'sets valid birthday' do
@@ -102,10 +104,11 @@ describe ProfilesController, :type => :controller do
:month => '02',
:day => '28' } } }
- put :update, params
- expect(eve.person(true).profile.birthday.year).to eq(2001)
- expect(eve.person(true).profile.birthday.month).to eq(2)
- expect(eve.person(true).profile.birthday.day).to eq(28)
+ put :update, params: params
+ birthday = eve.person.reload.profile.birthday
+ expect(birthday.year).to eq(2001)
+ expect(birthday.month).to eq(2)
+ expect(birthday.day).to eq(28)
end
it 'displays error for invalid birthday' do
@@ -116,7 +119,7 @@ describe ProfilesController, :type => :controller do
:month => '02',
:day => '31' } } }
- put :update, params
+ put :update, params: params
expect(flash[:error]).not_to be_blank
end
@@ -134,7 +137,7 @@ describe ProfilesController, :type => :controller do
it "doesn't overwrite the profile photo when an empty string is passed in" do
image_url = eve.person.profile.image_url
- put :update, @params
+ put :update, params: @params
expect(Person.find(eve.person.id).profile.image_url).to eq(image_url)
end
@@ -150,12 +153,12 @@ describe ProfilesController, :type => :controller do
it 'person_id' do
person = eve.person
profile = person.profile
- put :update, @profile_params
+ put :update, params: @profile_params
expect(profile.reload.person_id).to eq(person.id)
end
it 'diaspora handle' do
- put :update, @profile_params
+ put :update, params: @profile_params
expect(Person.find(eve.person.id).profile[:diaspora_handle]).not_to eq('abc@a.com')
end
end
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index d39edb683..91cf4603d 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -30,19 +30,19 @@ describe RegistrationsController, type: :controller do
end
it "redirects #create to the login page" do
- post :create, valid_params
+ post :create, params: valid_params
expect(flash[:error]).to eq(I18n.t("registrations.closed"))
expect(response).to redirect_to new_user_session_path
end
it "does not redirect if there is a valid invite token" do
code = InvitationCode.create(user: bob)
- get :new, invite: {token: code.token}
+ get :new, params: {invite: {token: code.token}}
expect(response).not_to be_redirect
end
it "does redirect if there is an invalid invite token" do
- get :new, invite: {token: "fssdfsd"}
+ get :new, params: {invite: {token: "fssdfsd"}}
expect(response).to redirect_to new_user_session_path
end
@@ -50,7 +50,7 @@ describe RegistrationsController, type: :controller do
code = InvitationCode.create(user: bob)
code.update_attributes(count: 0)
- get :new, invite: {token: code.token}
+ get :new, params: {invite: {token: code.token}}
expect(response).to redirect_to new_user_session_path
end
@@ -58,7 +58,7 @@ describe RegistrationsController, type: :controller do
code = InvitationCode.create(user: bob)
AppConfig.settings.invitations.open = false
- get :new, invite: {token: code.token}
+ get :new, params: {invite: {token: code.token}}
expect(response).to redirect_to new_user_session_path
end
@@ -68,7 +68,7 @@ describe RegistrationsController, type: :controller do
code = InvitationCode.create(user: bob)
code.update_attributes(count: 0)
- get :new, invite: {token: code.token}
+ get :new, params: {invite: {token: code.token}}
expect(response).not_to be_redirect
end
end
@@ -79,22 +79,22 @@ describe RegistrationsController, type: :controller do
context "with valid parameters" do
it "creates a user" do
expect {
- get :create, valid_params
+ get :create, params: valid_params
}.to change(User, :count).by(1)
end
it "assigns @user" do
- get :create, valid_params
+ get :create, params: valid_params
expect(assigns(:user)).to be_truthy
end
it "sets the flash" do
- get :create, valid_params
+ get :create, params: valid_params
expect(flash[:notice]).not_to be_blank
end
it "redirects to the home path" do
- get :create, valid_params
+ get :create, params: valid_params
expect(response).to be_redirect
expect(response.location).to match(/^#{getting_started_url}$/)
end
@@ -106,7 +106,7 @@ describe RegistrationsController, type: :controller do
code = InvitationCode.create(user: bob)
expect {
- get :create, valid_params.merge(invite: {token: code.token})
+ get :create, params: valid_params.merge(invite: {token: code.token})
}.to change { code.reload.count }.by(-1)
end
@@ -114,14 +114,14 @@ describe RegistrationsController, type: :controller do
code = InvitationCode.create(user: bob)
expect {
- get :create, valid_params.merge(invite: {token: code.token})
+ get :create, params: valid_params.merge(invite: {token: code.token})
}.not_to change { code.reload.count }
end
it "links inviter with the user" do
code = InvitationCode.create(user: bob)
- post :create, valid_params.merge(invite: {token: code.token})
+ post :create, params: valid_params.merge(invite: {token: code.token})
expect(User.find_by(username: "jdoe").invited_by).to eq(bob)
end
@@ -132,20 +132,20 @@ describe RegistrationsController, type: :controller do
let(:invalid_params) { valid_params.deep_merge(user: {password_confirmation: "baddword"}) }
it "does not create a user" do
- expect { get :create, invalid_params }.not_to change(User, :count)
+ expect { get :create, params: invalid_params }.not_to change(User, :count)
end
it "does not create a person" do
- expect { get :create, invalid_params }.not_to change(Person, :count)
+ expect { get :create, params: invalid_params }.not_to change(Person, :count)
end
it "assigns @user" do
- get :create, invalid_params
+ get :create, params: invalid_params
expect(assigns(:user)).not_to be_nil
end
it "sets the flash error" do
- get :create, invalid_params
+ get :create, params: invalid_params
expect(flash[:error]).not_to be_blank
end
@@ -155,17 +155,17 @@ describe RegistrationsController, type: :controller do
code = InvitationCode.create(user: bob)
expect {
- get :create, invalid_params.merge(invite: {token: code.token})
+ get :create, params: invalid_params.merge(invite: {token: code.token})
}.not_to change { code.reload.count }
end
it "renders new" do
- get :create, invalid_params
+ get :create, params: invalid_params
expect(response).to render_template("registrations/new")
end
it "keeps invalid params in form" do
- get :create, invalid_params
+ get :create, params: invalid_params
expect(response.body).to match /jdoe@example.com/m
end
end
diff --git a/spec/controllers/report_controller_spec.rb b/spec/controllers/report_controller_spec.rb
index bb049243c..176a1d4f8 100644
--- a/spec/controllers/report_controller_spec.rb
+++ b/spec/controllers/report_controller_spec.rb
@@ -46,14 +46,14 @@ describe ReportController, type: :controller do
context "report offensive post" do
it "succeeds" do
- put :create, report: {item_id: @message.id, item_type: "Post", text: "offensive content"}
+ put :create, params: {report: {item_id: @message.id, item_type: "Post", text: "offensive content"}}
expect(response.status).to eq(200)
expect(Report.exists?(item_id: @message.id, item_type: "Post")).to be true
end
end
context "report offensive comment" do
it "succeeds" do
- put :create, report: {item_id: @comment.id, item_type: "Comment", text: "offensive content"}
+ put :create, params: {report: {item_id: @comment.id, item_type: "Comment", text: "offensive content"}}
expect(response.status).to eq(200)
expect(Report.exists?(item_id: @comment.id, item_type: "Comment")).to be true
end
@@ -63,14 +63,14 @@ describe ReportController, type: :controller do
describe "#update" do
context "mark post report as user" do
it "is behind redirect_unless_admin_or_moderator" do
- put :update, id: @message.id, type: "post"
+ put :update, params: {id: @message.id, type: "post"}
expect(response).to redirect_to stream_path
expect(Report.where(reviewed: false, item_id: @message.id, item_type: "Post")).to be_truthy
end
end
context "mark comment report as user" do
it "is behind redirect_unless_admin_or_moderator" do
- put :update, id: @comment.id, type: "comment"
+ put :update, params: {id: @comment.id, type: "comment"}
expect(response).to redirect_to stream_path
expect(Report.where(reviewed: false, item_id: @comment.id, item_type: "Comment")).to be_truthy
end
@@ -81,7 +81,7 @@ describe ReportController, type: :controller do
Role.add_admin(alice.person)
end
it "succeeds" do
- put :update, id: @message.id, type: "post"
+ put :update, params: {id: @message.id, type: "post"}
expect(response.status).to eq(302)
expect(Report.where(reviewed: true, item_id: @message.id, item_type: "Post")).to be_truthy
end
@@ -91,7 +91,7 @@ describe ReportController, type: :controller do
Role.add_admin(alice.person)
end
it "succeeds" do
- put :update, id: @comment.id, type: "comment"
+ put :update, params: {id: @comment.id, type: "comment"}
expect(response.status).to eq(302)
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "Comment")).to be_truthy
end
@@ -103,7 +103,7 @@ describe ReportController, type: :controller do
end
it "succeeds" do
- put :update, id: @message.id, type: "post"
+ put :update, params: {id: @message.id, type: "post"}
expect(response.status).to eq(302)
expect(Report.where(reviewed: true, item_id: @message.id, item_type: "Post")).to be_truthy
end
@@ -114,7 +114,7 @@ describe ReportController, type: :controller do
Role.add_moderator(alice.person)
end
it "succeeds" do
- put :update, id: @comment.id, type: "comment"
+ put :update, params: {id: @comment.id, type: "comment"}
expect(response.status).to eq(302)
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "Comment")).to be_truthy
end
@@ -124,14 +124,14 @@ describe ReportController, type: :controller do
describe "#destroy" do
context "destroy post as user" do
it "is behind redirect_unless_admin_or_moderator" do
- delete :destroy, id: @message.id, type: "post"
+ delete :destroy, params: {id: @message.id, type: "post"}
expect(response).to redirect_to stream_path
expect(Report.where(reviewed: false, item_id: @message.id, item_type: "Post")).to be_truthy
end
end
context "destroy comment as user" do
it "is behind redirect_unless_admin_or_moderator" do
- delete :destroy, id: @comment.id, type: "comment"
+ delete :destroy, params: {id: @comment.id, type: "comment"}
expect(response).to redirect_to stream_path
expect(Report.where(reviewed: false, item_id: @comment.id, item_type: "Comment")).to be_truthy
end
@@ -142,7 +142,7 @@ describe ReportController, type: :controller do
Role.add_admin(alice.person)
end
it "succeeds" do
- delete :destroy, id: @message.id, type: "post"
+ delete :destroy, params: {id: @message.id, type: "post"}
expect(response.status).to eq(302)
expect(Report.where(reviewed: true, item_id: @message.id, item_type: "Post")).to be_truthy
end
@@ -152,7 +152,7 @@ describe ReportController, type: :controller do
Role.add_admin(alice.person)
end
it "succeeds" do
- delete :destroy, id: @comment.id, type: "comment"
+ delete :destroy, params: {id: @comment.id, type: "comment"}
expect(response.status).to eq(302)
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "Comment")).to be_truthy
end
@@ -163,7 +163,7 @@ describe ReportController, type: :controller do
Role.add_moderator(alice.person)
end
it "succeeds" do
- delete :destroy, id: @message.id, type: "post"
+ delete :destroy, params: {id: @message.id, type: "post"}
expect(response.status).to eq(302)
expect(Report.where(reviewed: true, item_id: @message.id, item_type: "Post")).to be_truthy
end
@@ -173,7 +173,7 @@ describe ReportController, type: :controller do
Role.add_moderator(alice.person)
end
it "succeeds" do
- delete :destroy, id: @comment.id, type: "comment"
+ delete :destroy, params: {id: @comment.id, type: "comment"}
expect(response.status).to eq(302)
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "Comment")).to be_truthy
end
diff --git a/spec/controllers/reshares_controller_spec.rb b/spec/controllers/reshares_controller_spec.rb
index 38a65b94e..4682baa23 100644
--- a/spec/controllers/reshares_controller_spec.rb
+++ b/spec/controllers/reshares_controller_spec.rb
@@ -1,7 +1,7 @@
describe ResharesController, :type => :controller do
describe '#create' do
let(:post_request!) {
- post :create, :format => :json, :root_guid => @post_guid
+ post :create, params: {root_guid: @post_guid}, format: :json
}
before do
@@ -74,13 +74,13 @@ describe ResharesController, :type => :controller do
it "returns a 404 for a post not visible to the user" do
sign_in(eve, scope: :user)
expect {
- get :index, post_id: @post.id, format: :json
+ get :index, params: {post_id: @post.id}, format: :json
}.to raise_error(ActiveRecord::RecordNotFound)
end
it "returns an empty array for a post visible to the user" do
sign_in(bob, scope: :user)
- get :index, post_id: @post.id, format: :json
+ get :index, params: {post_id: @post.id}, format: :json
expect(JSON.parse(response.body)).to eq([])
end
end
@@ -93,12 +93,12 @@ describe ResharesController, :type => :controller do
it "returns an array of reshares for a post" do
bob.reshare!(@post)
- get :index, post_id: @post.id, format: :json
+ get :index, params: {post_id: @post.id}, format: :json
expect(JSON.parse(response.body).map {|h| h["id"] }).to eq(@post.reshares.map(&:id))
end
it "returns an empty array for a post with no reshares" do
- get :index, post_id: @post.id, format: :json
+ get :index, params: {post_id: @post.id}, format: :json
expect(JSON.parse(response.body)).to eq([])
end
end
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index ab90b253b..655cb86d4 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -7,7 +7,7 @@ describe SearchController, :type => :controller do
describe 'query is a person' do
it 'goes to people index page' do
- get :search, :q => 'eugene'
+ get :search, params: {q: "eugene"}
expect(response).to be_redirect
end
end
@@ -15,17 +15,17 @@ describe SearchController, :type => :controller do
describe 'query is a tag' do
it 'goes to a tag page' do
- get :search, :q => '#cats'
+ get :search, params: {q: "#cats"}
expect(response).to redirect_to(tag_path('cats'))
end
it 'removes dots from the query' do
- get :search, :q => '#cat.s'
+ get :search, params: {q: "#cat.s"}
expect(response).to redirect_to(tag_path('cats'))
end
it 'stay on the page if you search for the empty hash' do
- get :search, :q => '#'
+ get :search, params: {q: "#"}
expect(flash[:error]).to be_present
end
end
diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb
index 75cff3391..9ad8e36aa 100644
--- a/spec/controllers/services_controller_spec.rb
+++ b/spec/controllers/services_controller_spec.rb
@@ -35,12 +35,12 @@ describe ServicesController, :type => :controller do
it 'creates a new service and associates it with the current user' do
expect {
- post :create, :provider => 'facebook'
+ post :create, params: {provider: "facebook"}
}.to change(user.services, :count).by(1)
end
it 'saves the provider' do
- post :create, :provider => 'facebook'
+ post :create, params: {provider: "facebook"}
expect(user.reload.services.first.class.name).to eq("Services::Facebook")
end
@@ -49,7 +49,7 @@ describe ServicesController, :type => :controller do
it "imports the profile photo from the service" do
expect(Workers::FetchProfilePhoto).to receive(:perform_async)
- post :create, :provider => 'facebook'
+ post :create, params: {provider: "facebook"}
end
end
@@ -58,12 +58,12 @@ describe ServicesController, :type => :controller do
it 'doesnt create a new service' do
service_count = Service.count
- post :create, :provider => 'twitter'
+ post :create, params: {provider: "twitter"}
expect(Service.count).to eq(service_count)
end
it 'flashes an already_authorized error with the diaspora handle for the user' do
- post :create, :provider => 'twitter'
+ post :create, params: {provider: "twitter"}
expect(flash[:error].include?(user.profile.diaspora_handle)).to be true
expect(flash[:error].include?( 'already authorized' )).to be true
end
@@ -84,12 +84,12 @@ describe ServicesController, :type => :controller do
it 'doesnt create a new service' do
service_count = Service.count
- post :create, :provider => 'twitter'
+ post :create, params: {provider: "twitter"}
expect(Service.count).to eq(service_count)
end
it 'flashes an read-only access error' do
- post :create, :provider => 'twitter'
+ post :create, params: {provider: "twitter"}
expect(flash[:error].include?( 'Access level is read-only' )).to be true
end
end
@@ -103,7 +103,7 @@ describe ServicesController, :type => :controller do
it "doesn't break when twitter-specific extras aren't available in omniauth hash" do
expect {
- post :create, :provider => 'facebook'
+ post :create, params: {provider: "facebook"}
}.to change(user.services, :count).by(1)
end
end
@@ -121,7 +121,7 @@ describe ServicesController, :type => :controller do
expect(Workers::FetchProfilePhoto).not_to receive(:perform_async)
- post :create, :provider => 'twitter'
+ post :create, params: {provider: "twitter"}
end
it 'queues a job to save user photo if the photo does not exist' do
@@ -129,7 +129,7 @@ describe ServicesController, :type => :controller do
expect(Workers::FetchProfilePhoto).to receive(:perform_async).with(user.id, anything(), "https://service.com/fallback_lowres.jpg")
- post :create, :provider => 'twitter'
+ post :create, params: {provider: "twitter"}
end
end
end
@@ -141,7 +141,7 @@ describe ServicesController, :type => :controller do
it 'destroys a service selected by id' do
expect{
- delete :destroy, :id => @service1.id
+ delete :destroy, params: {id: @service1.id}
}.to change(user.services, :count).by(-1)
end
end
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index 55ae17bae..69bbf510c 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -15,14 +15,14 @@ describe SessionsController, type: :controller do
describe "#create" do
it "redirects to /stream for a non-mobile user" do
- post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
+ post :create, params: {user: {remember_me: "0", username: @user.username, password: "evankorth"}}
expect(response).to be_redirect
expect(response.location).to match /^#{stream_url}\??$/
end
it "redirects to /stream for a mobile user" do
request.headers["X_MOBILE_DEVICE"] = true
- post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
+ post :create, params: {user: {remember_me: "0", username: @user.username, password: "evankorth"}}
expect(response).to be_redirect
expect(response.location).to match /^#{stream_url}\??$/
end
diff --git a/spec/controllers/share_visibilities_controller_spec.rb b/spec/controllers/share_visibilities_controller_spec.rb
index 30c0151e9..f70a50ea3 100644
--- a/spec/controllers/share_visibilities_controller_spec.rb
+++ b/spec/controllers/share_visibilities_controller_spec.rb
@@ -14,13 +14,13 @@ describe ShareVisibilitiesController, :type => :controller do
end
it 'succeeds' do
- put :update, :format => :js, :id => 42, :post_id => @status.id
+ put :update, params: {id: 42, post_id: @status.id}, format: :js
expect(response).to be_success
end
it 'it calls toggle_hidden_shareable' do
expect(@controller.current_user).to receive(:toggle_hidden_shareable).with(an_instance_of(StatusMessage))
- put :update, :format => :js, :id => 42, :post_id => @status.id
+ put :update, params: {id: 42, post_id: @status.id}, format: :js
end
end
@@ -31,14 +31,14 @@ describe ShareVisibilitiesController, :type => :controller do
it "raises an error" do
expect {
- put :update, format: :js, id: 42, post_id: @status.id
+ put :update, params: {id: 42, post_id: @status.id}, format: :js
}.to raise_error ActiveRecord::RecordNotFound
end
it "it doesn't call toggle_hidden_shareable" do
expect(@controller.current_user).not_to receive(:toggle_hidden_shareable).with(an_instance_of(StatusMessage))
begin
- put :update, format: :js, id: 42, post_id: @status.id
+ put :update, params: {id: 42, post_id: @status.id}, format: :js
rescue ActiveRecord::RecordNotFound
end
end
diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb
index 62fba474c..8b99c04c2 100644
--- a/spec/controllers/status_messages_controller_spec.rb
+++ b/spec/controllers/status_messages_controller_spec.rb
@@ -27,16 +27,18 @@ describe StatusMessagesController, :type => :controller do
end
it 'accepts get params' do
- get :bookmarklet, { url: 'https://www.youtube.com/watch?v=0Bmhjf0rKe8',
- title: 'Surprised Kitty',
- notes: 'cute kitty' }
+ get :bookmarklet, params: {
+ url: "https://www.youtube.com/watch?v=0Bmhjf0rKe8",
+ title: "Surprised Kitty",
+ notes: "cute kitty"
+ }
expect(response).to be_success
end
end
describe '#new' do
it 'succeeds' do
- get :new, :person_id => bob.person.id
+ get :new, params: {person_id: bob.person.id}
expect(response).to be_success
end
@@ -55,43 +57,31 @@ describe StatusMessagesController, :type => :controller do
}
}
- it 'creates with valid html' do
- post :create, status_message_hash
- expect(response.status).to eq(302)
- expect(response).to be_redirect
- end
-
- it 'creates with invalid html' do
- post :create, status_message_hash.merge(:status_message => { :text => "0123456789" * 7000 })
- expect(response.status).to eq(302)
- expect(response).to be_redirect
- end
-
it 'creates with valid json' do
- post :create, status_message_hash.merge(:format => 'json')
+ post :create, params: status_message_hash, format: :json
expect(response.status).to eq(201)
end
it 'creates with invalid json' do
- post :create, status_message_hash.merge(:status_message => { :text => "0123456789" * 7000 }, :format => 'json')
+ post :create, params: status_message_hash.merge(status_message: {text: "0123456789" * 7000}), format: :json
expect(response.status).to eq(403)
end
it 'creates with valid mobile' do
- post :create, status_message_hash.merge(:format => 'mobile')
+ post :create, params: status_message_hash, format: :mobile
expect(response.status).to eq(302)
expect(response).to be_redirect
end
it 'creates with invalid mobile' do
- post :create, status_message_hash.merge(:status_message => { :text => "0123456789" * 7000 }, :format => 'mobile')
+ post :create, params: status_message_hash.merge(status_message: {text: "0123456789" * 7000}), format: :mobile
expect(response.status).to eq(302)
expect(response).to be_redirect
end
it 'removes getting started from new users' do
expect(@controller).to receive(:remove_getting_started)
- post :create, status_message_hash
+ post :create, params: status_message_hash
end
context "with aspect_ids" do
@@ -100,43 +90,43 @@ describe StatusMessagesController, :type => :controller do
end
it "takes one aspect as array in aspect_ids" do
- post :create, status_message_hash
- expect(response.status).to eq(302)
+ post :create, params: status_message_hash, format: :json
+ expect(response.status).to eq(201)
status_message = StatusMessage.find_by_text(text)
- expect(status_message.aspect_visibilities.map(&:aspect)).to eq([@aspect1])
+ expect(status_message.aspect_visibilities.map(&:aspect)).to eq([@aspect1]), format: :json
end
it "takes one aspect as string in aspect_ids" do
- post :create, status_message_hash.merge(aspect_ids: @aspect1.id.to_s)
- expect(response.status).to eq(302)
+ post :create, params: status_message_hash.merge(aspect_ids: @aspect1.id.to_s), format: :json
+ expect(response.status).to eq(201)
status_message = StatusMessage.find_by_text(text)
expect(status_message.aspect_visibilities.map(&:aspect)).to eq([@aspect1])
end
it "takes public as array in aspect_ids" do
- post :create, status_message_hash.merge(aspect_ids: ["public"])
- expect(response.status).to eq(302)
+ post :create, params: status_message_hash.merge(aspect_ids: ["public"]), format: :json
+ expect(response.status).to eq(201)
status_message = StatusMessage.find_by_text(text)
expect(status_message.public).to be_truthy
end
it "takes public as string in aspect_ids" do
- post :create, status_message_hash.merge(aspect_ids: "public")
- expect(response.status).to eq(302)
+ post :create, params: status_message_hash.merge(aspect_ids: "public"), format: :json
+ expect(response.status).to eq(201)
status_message = StatusMessage.find_by_text(text)
expect(status_message.public).to be_truthy
end
it "takes all_aspects as array in aspect_ids" do
- post :create, status_message_hash.merge(aspect_ids: ["all_aspects"])
- expect(response.status).to eq(302)
+ post :create, params: status_message_hash.merge(aspect_ids: ["all_aspects"]), format: :json
+ expect(response.status).to eq(201)
status_message = StatusMessage.find_by_text(text)
expect(status_message.aspect_visibilities.map(&:aspect)).to match_array([@aspect1, @aspect2])
end
it "takes all_aspects as string in aspect_ids" do
- post :create, status_message_hash.merge(aspect_ids: "all_aspects")
- expect(response.status).to eq(302)
+ post :create, params: status_message_hash.merge(aspect_ids: "all_aspects"), format: :json
+ expect(response.status).to eq(201)
status_message = StatusMessage.find_by_text(text)
expect(status_message.aspect_visibilities.map(&:aspect)).to match_array([@aspect1, @aspect2])
end
@@ -149,7 +139,7 @@ describe StatusMessagesController, :type => :controller do
status_message_hash[:services] = ['facebook']
service_types = Service.titles(status_message_hash[:services])
expect(alice).to receive(:dispatch_post).with(anything(), hash_including(:service_types => service_types))
- post :create, status_message_hash
+ post :create, params: status_message_hash
end
it "works if services is a string" do
@@ -157,12 +147,12 @@ describe StatusMessagesController, :type => :controller do
alice.services << s1
status_message_hash[:services] = "facebook"
expect(alice).to receive(:dispatch_post).with(anything(), hash_including(:service_types => ["Services::Facebook"]))
- post :create, status_message_hash
+ post :create, params: status_message_hash
end
it "doesn't overwrite author_id" do
status_message_hash[:status_message][:author_id] = bob.person.id
- post :create, status_message_hash
+ post :create, params: status_message_hash
new_message = StatusMessage.find_by_text(text)
expect(new_message.author_id).to eq(alice.person.id)
end
@@ -170,7 +160,7 @@ describe StatusMessagesController, :type => :controller do
it "doesn't overwrite id" do
old_status_message = alice.post(:status_message, :text => "hello", :to => @aspect1.id)
status_message_hash[:status_message][:id] = old_status_message.id
- post :create, status_message_hash
+ post :create, params: status_message_hash
expect(old_status_message.reload.text).to eq('hello')
end
@@ -178,18 +168,18 @@ describe StatusMessagesController, :type => :controller do
expect(alice).to receive(:dispatch_post) {|post, _opts|
expect(post.subscribers).to eq([bob.person])
}
- post :create, status_message_hash
+ post :create, params: status_message_hash
end
it 'respsects provider_display_name' do
status_message_hash.merge!(:aspect_ids => ['public'])
status_message_hash[:status_message].merge!(:provider_display_name => "mobile")
- post :create, status_message_hash
+ post :create, params: status_message_hash
expect(StatusMessage.first.provider_display_name).to eq('mobile')
end
it "has no participation" do
- post :create, status_message_hash
+ post :create, params: status_message_hash
new_message = StatusMessage.find_by_text(text)
expect(new_message.participations.count).to eq(0)
end
@@ -208,19 +198,19 @@ describe StatusMessagesController, :type => :controller do
it "will post a photo without text" do
@hash.delete :text
- post :create, @hash
- expect(response).to be_redirect
+ post :create, params: @hash, format: :json
+ expect(response.status).to eq(201)
end
it "attaches all referenced photos" do
- post :create, @hash
+ post :create, params: @hash, format: :json
status_message = StatusMessage.find_by_text(text)
expect(status_message.photos.map(&:id)).to match_array([@photo1, @photo2].map(&:id))
end
it "sets the pending bit of referenced photos" do
inlined_jobs do
- post :create, @hash
+ post :create, params: @hash, format: :json
end
expect(@photo1.reload.pending).to be false
diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb
index 3b49bccbc..b62adc5b0 100644
--- a/spec/controllers/tags_controller_spec.rb
+++ b/spec/controllers/tags_controller_spec.rb
@@ -12,13 +12,13 @@ describe TagsController, :type => :controller do
end
it 'responds with json' do
- get :index, :q => "ra", :format => 'json'
+ get :index, params: {q: "ra"}, format: :json
#parse json
expect(response.body).to include("#rad")
end
it 'requires at least two characters' do
- get :index, :q => "c", :format => 'json'
+ get :index, params: {q: "c"}, format: :json
expect(response.body).not_to include("#cats")
end
@@ -28,7 +28,7 @@ describe TagsController, :type => :controller do
end
it 'does not allow json requestors to party' do
- get :index, :format => :json
+ get :index, format: :json
expect(response.status).to eq(422)
end
end
@@ -40,7 +40,7 @@ describe TagsController, :type => :controller do
end
it 'redirect to the downcase tag uri' do
- get :show, :name => 'DiasporaRocks!'
+ get :show, params: {name: "DiasporaRocks!"}
expect(response).to redirect_to(:action => :show, :name => 'diasporarocks!')
end
end
@@ -53,7 +53,7 @@ describe TagsController, :type => :controller do
end
it 'includes the tagged user' do
- get :show, :name => 'cats'
+ get :show, params: {name: "cats"}
expect(response.body).to include(bob.diaspora_handle)
end
end
@@ -69,40 +69,40 @@ describe TagsController, :type => :controller do
end
it 'assigns a Stream::Tag object with the current_user' do
- get :show, :name => 'yes'
+ get :show, params: {name: "yes"}
expect(assigns[:stream].user).to eq(alice)
end
it 'succeeds' do
- get :show, :name => 'hellyes'
+ get :show, params: {name: "hellyes"}
expect(response.status).to eq(200)
end
it 'includes the tagged post' do
- get :show, :name => 'foo'
+ get :show, params: {name: "foo"}
expect(assigns[:stream].posts.first.text).to include("tagged post")
end
it 'includes comments of the tagged post' do
alice.comment!(@post, "comment on a tagged post")
- get :show, :name => 'foo', :format => 'json'
+ get :show, params: {name: "foo"}, format: :json
expect(response.body).to include("comment on a tagged post")
end
end
context "not signed in" do
it 'assigns a Stream::Tag object with no user' do
- get :show, :name => 'yes'
+ get :show, params: {name: "yes"}
expect(assigns[:stream].user).to be_nil
end
it 'succeeds' do
- get :show, :name => 'hellyes'
+ get :show, params: {name: "hellyes"}
expect(response.status).to eq(200)
end
it 'succeeds with mobile' do
- get :show, :name => 'foo', :format => :mobile
+ get :show, params: {name: "foo"}, format: :mobile
expect(response).to be_success
end
@@ -113,7 +113,7 @@ describe TagsController, :type => :controller do
public: true,
created_at: @post.created_at - 1.day
)
- get :show, name: "what", max_time: @post.created_at, format: :json
+ get :show, params: {name: "what", max_time: @post.created_at.to_i}, format: :json
expect(JSON.parse(response.body).size).to be(1)
expect(JSON.parse(response.body).first["guid"]).to eq(post2.guid)
end
@@ -122,7 +122,7 @@ describe TagsController, :type => :controller do
it "includes the correct meta tags" do
tag_url = tag_url "yes", host: AppConfig.pod_uri.host, port: AppConfig.pod_uri.port
- get :show, name: "yes"
+ get :show, params: {name: "yes"}
expect(response.body).to include('')
expect(response.body).to include(
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index b68b96a95..e3ef6a785 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -58,26 +58,26 @@ describe UsersController, :type => :controller do
end
it "contains the text" do
- get :public, username: @user.username, format: :atom
+ get :public, params: {username: @user.username}, format: :atom
doc = Nokogiri::XML(response.body)
expect(doc.css("entry content")[0].content).to eq(@sm.message.markdownified(disable_hovercards: true))
end
it "contains the title" do
- get :public, username: @user.username, format: :atom
+ get :public, params: {username: @user.username}, format: :atom
doc = Nokogiri::XML(response.body)
expect(doc.css("entry title")[0].content).to eq(post_page_title(@sm))
end
it "contains the author" do
- get :public, username: @user.username, format: :atom
+ get :public, params: {username: @user.username}, format: :atom
doc = Nokogiri::XML(response.body)
expect(doc.css("entry author name")[0].content).to eq(@sm.author_name)
end
it "contains the original author for reshares" do
FactoryGirl.create(:reshare, root: @sm, author: bob.person)
- get :public, username: bob.username, format: :atom
+ get :public, params: {username: bob.username}, format: :atom
doc = Nokogiri::XML(response.body)
expect(doc.css("entry author name")[0].content).to eq(@sm.author_name)
end
@@ -85,7 +85,7 @@ describe UsersController, :type => :controller do
it 'includes reshares in the atom feed' do
reshare = FactoryGirl.create(:reshare, :author => @user.person)
- get :public, :username => @user.username, :format => :atom
+ get :public, params: {username: @user.username}, format: :atom
expect(response.body).to include reshare.root.text
end
@@ -93,17 +93,17 @@ describe UsersController, :type => :controller do
post = FactoryGirl.create(:status_message, :public => true);
reshare = FactoryGirl.create(:reshare, :root => post, :author => @user.person)
post.delete
- get :public, :username => @user.username, :format => :atom
+ get :public, params: {username: @user.username}, format: :atom
expect(response.code).to eq('200')
end
it 'redirects to a profile page if html is requested' do
- get :public, :username => @user.username
+ get :public, params: {username: @user.username}
expect(response).to be_redirect
end
it 'redirects to a profile page if mobile is requested' do
- get :public, :username => @user.username, :format => :mobile
+ get :public, params: {username: @user.username}, format: :mobile
expect(response).to be_redirect
end
end
@@ -116,12 +116,12 @@ describe UsersController, :type => :controller do
it "doesn't overwrite random attributes" do
expect {
- put :update, @params
+ put :update, params: @params
}.not_to change(@user, :diaspora_handle)
end
it 'renders the user edit page' do
- put :update, @params
+ put :update, params: @params
expect(response).to render_template('edit')
end
@@ -139,7 +139,7 @@ describe UsersController, :type => :controller do
it "uses devise's update with password" do
expect(@user).to receive(:update_with_password).with(hash_including(password_params))
allow(@controller).to receive(:current_user).and_return(@user)
- put :update, params
+ put :update, params: params
end
end
@@ -148,9 +148,7 @@ describe UsersController, :type => :controller do
old_language = 'en'
@user.language = old_language
@user.save
- put(:update, :id => @user.id, :user =>
- { :language => "fr"}
- )
+ put :update, params: {id: @user.id, user: {language: "fr"}}
@user.reload
expect(@user.language).not_to eq(old_language)
end
@@ -161,7 +159,7 @@ describe UsersController, :type => :controller do
old_color_theme = "original"
@user.color_theme = old_color_theme
@user.save
- put(:update, id: @user.id, user: {color_theme: "dark_green"})
+ put :update, params: {id: @user.id, user: {color_theme: "dark_green"}}
@user.reload
expect(@user.color_theme).not_to eq(old_color_theme)
end
@@ -170,43 +168,43 @@ describe UsersController, :type => :controller do
describe 'email' do
it 'disallow the user to change his new (unconfirmed) mail when it is the same as the old' do
@user.email = "my@newemail.com"
- put(:update, :id => @user.id, :user => { :email => "my@newemail.com"})
+ put :update, params: {id: @user.id, user: {email: "my@newemail.com"}}
@user.reload
expect(@user.unconfirmed_email).to eql(nil)
end
it 'allow the user to change his (unconfirmed) email' do
- put(:update, :id => @user.id, :user => { :email => "my@newemail.com"})
+ put :update, params: {id: @user.id, user: {email: "my@newemail.com"}}
@user.reload
expect(@user.unconfirmed_email).to eql("my@newemail.com")
end
it 'informs the user about success' do
- put(:update, :id => @user.id, :user => { :email => "my@newemail.com"})
+ put :update, params: {id: @user.id, user: {email: "my@newemail.com"}}
expect(request.flash[:notice]).to eql(I18n.t('users.update.unconfirmed_email_changed'))
expect(request.flash[:error]).to be_blank
end
it 'informs the user about failure' do
- put(:update, id: @user.id, user: {email: "mynewemailcom"})
+ put :update, params: {id: @user.id, user: {email: "mynewemailcom"}}
expect(request.flash[:error]).to eql(I18n.t('users.update.unconfirmed_email_not_changed'))
expect(request.flash[:notice]).to be_blank
end
it 'allow the user to change his (unconfirmed) email to blank (= abort confirmation)' do
- put(:update, :id => @user.id, :user => { :email => ""})
+ put :update, params: {id: @user.id, user: {email: ""}}
@user.reload
expect(@user.unconfirmed_email).to eql(nil)
end
it 'sends out activation email on success' do
expect(Workers::Mail::ConfirmEmail).to receive(:perform_async).with(@user.id).once
- put(:update, :id => @user.id, :user => { :email => "my@newemail.com"})
+ put :update, params: {id: @user.id, user: {email: "my@newemail.com"}}
end
it "saves unconfirmed_email when podmail is disabled" do
AppConfig.mail.enable = false
- put(:update, id: @user.id, user: {email: "my@newemail.com"})
+ put :update, params: {id: @user.id, user: {email: "my@newemail.com"}}
@user.reload
expect(@user.email).to eql("my@newemail.com")
end
@@ -218,7 +216,7 @@ describe UsersController, :type => :controller do
it "lets the user turn off mail" do
par = {id: @user.id, user: {email_preferences: {email_type => "true"}}}
expect {
- put :update, par
+ put :update, params: par
}.to change(@user.user_preferences, :count).by(1)
end
@@ -226,7 +224,7 @@ describe UsersController, :type => :controller do
@user.user_preferences.create(email_type: email_type)
par = {id: @user.id, user: {email_preferences: {email_type => "false"}}}
expect {
- put :update, par
+ put :update, params: par
}.to change(@user.user_preferences, :count).by(-1)
end
end
@@ -235,7 +233,7 @@ describe UsersController, :type => :controller do
describe 'getting started' do
it 'can be reenabled' do
- put :update, user: {getting_started: true}
+ put :update, params: {user: {getting_started: true}}
expect(@user.reload.getting_started?).to be true
end
end
@@ -250,32 +248,32 @@ describe UsersController, :type => :controller do
describe '#edit' do
it "returns a 200" do
- get 'edit', :id => @user.id
+ get :edit, params: {id: @user.id}
expect(response.status).to eq(200)
end
it 'displays community spotlight checkbox' do
AppConfig.settings.community_spotlight.enable = true
- get 'edit', :id => @user.id
+ get :edit, params: {id: @user.id}
expect(response.body).to include('input name="user[show_community_spotlight_in_stream]"')
end
it 'hides community spotlight checkbox' do
AppConfig.settings.community_spotlight = false
- get 'edit', :id => @user.id
+ get :edit, params: {id: @user.id}
expect(response.body).not_to include('input name="user[show_community_spotlight_in_stream]"')
end
it 'set @email_pref to false when there is a user pref' do
@user.user_preferences.create(:email_type => 'mentioned')
- get 'edit', :id => @user.id
+ get :edit, params: {id: @user.id}
expect(assigns[:email_prefs]['mentioned']).to be false
end
it "does not allow token auth" do
sign_out :user
bob.reset_authentication_token!
- get :edit, :auth_token => bob.authentication_token
+ get :edit, params: {auth_token: bob.authentication_token}
expect(response).to redirect_to new_user_session_path
end
end
@@ -283,17 +281,17 @@ describe UsersController, :type => :controller do
describe '#destroy' do
it 'does nothing if the password does not match' do
expect(Workers::DeleteAccount).not_to receive(:perform_async)
- delete :destroy, :user => { :current_password => "stuff" }
+ delete :destroy, params: {user: {current_password: "stuff"}}
end
it 'closes the account' do
expect(alice).to receive(:close_account!)
- delete :destroy, :user => { :current_password => "bluepin7" }
+ delete :destroy, params: {user: {current_password: "bluepin7"}}
end
it 'enqueues a delete job' do
expect(Workers::DeleteAccount).to receive(:perform_async).with(anything)
- delete :destroy, :user => { :current_password => "bluepin7" }
+ delete :destroy, params: {user: {current_password: "bluepin7"}}
end
end
@@ -303,12 +301,12 @@ describe UsersController, :type => :controller do
end
it 'redirects to to the user edit page' do
- get 'confirm_email', :token => @user.confirm_email_token
+ get :confirm_email, params: {token: @user.confirm_email_token}
expect(response).to redirect_to edit_user_path
end
it 'confirms email' do
- get 'confirm_email', :token => @user.confirm_email_token
+ get :confirm_email, params: {token: @user.confirm_email_token}
@user.reload
expect(@user.email).to eql('my@newemail.com')
expect(request.flash[:notice]).to eql(I18n.t('users.confirm_email.email_confirmed', :email => 'my@newemail.com'))
@@ -316,7 +314,7 @@ describe UsersController, :type => :controller do
end
it 'does NOT confirm email with wrong token' do
- get 'confirm_email', :token => @user.confirm_email_token.reverse
+ get :confirm_email, params: {token: @user.confirm_email_token.reverse}
@user.reload
expect(@user.email).not_to eql('my@newemail.com')
expect(request.flash[:error]).to eql(I18n.t('users.confirm_email.email_not_confirmed'))
@@ -331,7 +329,7 @@ describe UsersController, :type => :controller do
end
it 'does not fail miserably on mobile' do
- get :getting_started, :format => :mobile
+ get :getting_started, format: :mobile
expect(response).to be_success
end
diff --git a/spec/factories.rb b/spec/factories.rb
index 30c8cb5ac..d3fc152d8 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -360,35 +360,15 @@ FactoryGirl.define do
factory(:status, :parent => :status_message)
factory :o_auth_application, class: Api::OpenidConnect::OAuthApplication do
- client_name "Diaspora Test Client"
+ client_name { "Diaspora Test Client #{r_str}" }
redirect_uris %w(http://localhost:3000/)
end
- factory :o_auth_application_with_image, class: Api::OpenidConnect::OAuthApplication do
- client_name "Diaspora Test Client"
- redirect_uris %w(http://localhost:3000/)
- logo_uri "/assets/user/default.png"
- end
-
- factory :o_auth_application_with_ppid, class: Api::OpenidConnect::OAuthApplication do
- client_name "Diaspora Test Client"
- redirect_uris %w(http://localhost:3000/)
+ factory :o_auth_application_with_ppid, parent: :o_auth_application do
ppid true
sector_identifier_uri "https://example.com/uri"
end
- factory :o_auth_application_with_ppid_with_specific_id, class: Api::OpenidConnect::OAuthApplication do
- client_name "Diaspora Test Client"
- redirect_uris %w(http://localhost:3000/)
- ppid true
- sector_identifier_uri "https://example.com/uri"
- end
-
- factory :o_auth_application_with_multiple_redirects, class: Api::OpenidConnect::OAuthApplication do
- client_name "Diaspora Test Client"
- redirect_uris %w(http://localhost:3000/ http://localhost/)
- end
-
factory :o_auth_application_with_xss, class: Api::OpenidConnect::OAuthApplication do
client_name ""
redirect_uris %w(http://localhost:3000/)
diff --git a/spec/integration/api/user_info_controller_spec.rb b/spec/integration/api/user_info_controller_spec.rb
index eaff50459..2c692a100 100644
--- a/spec/integration/api/user_info_controller_spec.rb
+++ b/spec/integration/api/user_info_controller_spec.rb
@@ -5,7 +5,7 @@ describe Api::OpenidConnect::UserInfoController do
describe "#show" do
before do
@user = auth_with_read_and_ppid.user
- get api_openid_connect_user_info_path, access_token: access_token_with_read
+ get api_openid_connect_user_info_path, params: {access_token: access_token_with_read}
end
it "shows the info" do
diff --git a/spec/integration/application_spec.rb b/spec/integration/application_spec.rb
index 39c6c0d67..2c4e78fd5 100644
--- a/spec/integration/application_spec.rb
+++ b/spec/integration/application_spec.rb
@@ -10,14 +10,14 @@ describe ApplicationController, type: :request do
it "redirects to the new session page on validation fails" do
expect_any_instance_of(SessionsController).to receive(:verified_request?).and_return(false)
- post "/users/sign_in", user: {remember_me: 0, username: @user.username, password: "evankorth"}
+ post "/users/sign_in", params: {user: {remember_me: 0, username: @user.username, password: "evankorth"}}
expect(response).to redirect_to new_user_session_path
expect(flash[:error]).to eq(I18n.t("error_messages.csrf_token_fail"))
end
it "doesn't redirect to the new session page if the validation succeeded" do
expect_any_instance_of(SessionsController).to receive(:verified_request?).and_return(true)
- post "/users/sign_in", user: {remember_me: 0, username: @user.username, password: "evankorth"}
+ post "/users/sign_in", params: {user: {remember_me: 0, username: @user.username, password: "evankorth"}}
expect(response).to redirect_to stream_path
expect(flash[:error]).to be_blank
end
@@ -30,7 +30,7 @@ describe ApplicationController, type: :request do
it "signs out users if a wrong token was given" do
expect_any_instance_of(UsersController).to receive(:verified_request?).and_return(false)
- put edit_user_path, user: {language: "en"}
+ put edit_user_path, params: {user: {language: "en"}}
expect(response).to redirect_to new_user_session_path
expect(flash[:error]).to eq(I18n.t("error_messages.csrf_token_fail"))
end
@@ -38,12 +38,12 @@ describe ApplicationController, type: :request do
it "sends an email to the current user if the token validation failed" do
expect_any_instance_of(UsersController).to receive(:verified_request?).and_return(false)
expect(Workers::Mail::CsrfTokenFail).to receive(:perform_async).with(alice.id)
- put edit_user_path, user: {language: "en"}
+ put edit_user_path, params: {user: {language: "en"}}
end
it "doesn't sign out users if the token was correct" do
expect_any_instance_of(UsersController).to receive(:verified_request?).and_return(true)
- put edit_user_path, user: {language: "en"}
+ put edit_user_path, params: {user: {language: "en"}}
expect(response).not_to be_redirect
expect(flash[:error]).to be_blank
end
diff --git a/spec/integration/federation/attack_vectors_spec.rb b/spec/integration/federation/attack_vectors_spec.rb
index b7dcbbe5b..b88d4883c 100644
--- a/spec/integration/federation/attack_vectors_spec.rb
+++ b/spec/integration/federation/attack_vectors_spec.rb
@@ -36,7 +36,7 @@ describe "attack vectors", type: :request do
post_message(generate_payload(Diaspora::Federation::Entities.profile(profile), alice, bob), bob)
- expect(eve.profile(true).first_name).not_to eq("Not BOB")
+ expect(eve.profile.reload.first_name).not_to eq("Not BOB")
end
it "public post should not be spoofed from another author" do
@@ -59,14 +59,14 @@ describe "attack vectors", type: :request do
it "should not receive contact retractions from another person" do
# we are banking on bob being friends with alice and eve
# here, alice is trying to disconnect bob and eve
- contact = bob.contacts(true).find_by(person_id: eve.person.id)
+ contact = bob.contacts.reload.find_by(person_id: eve.person.id)
expect(contact).to be_sharing
post_message(
generate_payload(Diaspora::Federation::Entities.retraction(ContactRetraction.for(contact)), alice, bob), bob
)
- expect(bob.contacts(true).find_by(person_id: eve.person.id)).to be_sharing
+ expect(bob.contacts.reload.find_by(person_id: eve.person.id)).to be_sharing
end
end
diff --git a/spec/integration/federation/federation_helper.rb b/spec/integration/federation/federation_helper.rb
index 3525c95fe..58e95f908 100644
--- a/spec/integration/federation/federation_helper.rb
+++ b/spec/integration/federation/federation_helper.rb
@@ -61,12 +61,12 @@ def post_message(payload, recipient=nil)
if recipient
inlined_jobs do
headers = {"CONTENT_TYPE" => "application/json"}
- post "/receive/users/#{recipient.guid}", payload, headers
+ post "/receive/users/#{recipient.guid}", params: payload, headers: headers
end
else
inlined_jobs do
headers = {"CONTENT_TYPE" => "application/magic-envelope+xml"}
- post "/receive/public", payload, headers
+ post "/receive/public", params: payload, headers: headers
end
end
end
diff --git a/spec/integration/mentioning_spec.rb b/spec/integration/mentioning_spec.rb
index 94bd5f8cf..41a231d3e 100644
--- a/spec/integration/mentioning_spec.rb
+++ b/spec/integration/mentioning_spec.rb
@@ -51,7 +51,10 @@ module MentioningSpecHelpers
sign_in user1
status_msg = nil
inlined_jobs do
- post "/status_messages.json", status_message: {text: text_mentioning(mentioned_user)}, aspect_ids: aspects
+ post "/status_messages.json", params: {
+ status_message: {text: text_mentioning(mentioned_user)},
+ aspect_ids: aspects
+ }
status_msg = StatusMessage.find(JSON.parse(response.body)["id"])
end
status_msg
diff --git a/spec/integration/mobile_posts_spec.rb b/spec/integration/mobile_posts_spec.rb
index 1ffd10a79..1b5e53509 100644
--- a/spec/integration/mobile_posts_spec.rb
+++ b/spec/integration/mobile_posts_spec.rb
@@ -3,7 +3,7 @@ describe PostsController, type: :request do
let(:sm) { FactoryGirl.build(:status_message_with_poll, public: true) }
it "displays the poll" do
- get "/posts/#{sm.id}", format: :mobile
+ get "/posts/#{sm.id}", params: {format: :mobile}
expect(response.status).to eq(200)
expect(response.body).to match(/div class='poll'/)
@@ -13,7 +13,7 @@ describe PostsController, type: :request do
it "displays the correct percentage for the answers" do
alice.participate_in_poll!(sm, sm.poll.poll_answers.first)
bob.participate_in_poll!(sm, sm.poll.poll_answers.last)
- get "/posts/#{sm.id}", format: :mobile
+ get "/posts/#{sm.id}", params: {format: :mobile}
expect(response.status).to eq(200)
expect(response.body).to match(/div class='percentage pull-right'>\n50%/)
@@ -24,7 +24,7 @@ describe PostsController, type: :request do
let(:sm) { FactoryGirl.build(:status_message_with_location, public: true) }
it "displays the location" do
- get "/posts/#{sm.id}", format: :mobile
+ get "/posts/#{sm.id}", params: {format: :mobile}
expect(response.status).to eq(200)
expect(response.body).to match(/'location nsfw-hidden'/)
diff --git a/spec/integration/tag_people_spec.rb b/spec/integration/tag_people_spec.rb
index 336b7acf0..22b07d851 100644
--- a/spec/integration/tag_people_spec.rb
+++ b/spec/integration/tag_people_spec.rb
@@ -1,4 +1,4 @@
-describe TagsController, :type => :request do
+describe TagsController, type: :request do
describe 'will_paginate people on the tag page' do
let(:people) { (1..2).map { FactoryGirl.create(:person) } }
let(:tag) { "diaspora" }
@@ -17,7 +17,7 @@ describe TagsController, :type => :request do
end
it 'fetches the second page' do
- get "/tags/#{tag}", page: 2
+ get "/tags/#{tag}", params: {page: 2}
expect(response.status).to eq(200)
expect(response.body).to match(/2<\/a><\/li>/)
diff --git a/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb b/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb
index e93a995ef..fc2f4cb11 100644
--- a/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb
+++ b/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb
@@ -11,7 +11,7 @@ describe Api::OpenidConnect::ProtectedResourceEndpoint, type: :request do
context "when valid access token is provided" do
before do
- get api_openid_connect_user_info_path, access_token: access_token_with_read
+ get api_openid_connect_user_info_path, params: {access_token: access_token_with_read}
end
it "includes private in the cache-control header" do
@@ -21,7 +21,7 @@ describe Api::OpenidConnect::ProtectedResourceEndpoint, type: :request do
context "when access token is expired" do
before do
- get api_openid_connect_user_info_path, access_token: expired_access_token
+ get api_openid_connect_user_info_path, params: {access_token: expired_access_token}
end
it "should respond with a 401 Unauthorized response" do
@@ -47,7 +47,7 @@ describe Api::OpenidConnect::ProtectedResourceEndpoint, type: :request do
context "when an invalid access token is provided" do
before do
- get api_openid_connect_user_info_path, access_token: invalid_token
+ get api_openid_connect_user_info_path, params: {access_token: invalid_token}
end
it "should respond with a 401 Unauthorized response" do
@@ -66,7 +66,7 @@ describe Api::OpenidConnect::ProtectedResourceEndpoint, type: :request do
context "when authorization has been destroyed" do
before do
auth_with_read.destroy
- get api_openid_connect_user_info_path, access_token: access_token_with_read
+ get api_openid_connect_user_info_path, params: {access_token: access_token_with_read}
end
it "should respond with a 401 Unauthorized response" do
diff --git a/spec/lib/api/openid_connect/token_endpoint_spec.rb b/spec/lib/api/openid_connect/token_endpoint_spec.rb
index a455f8ffa..440d8132a 100644
--- a/spec/lib/api/openid_connect/token_endpoint_spec.rb
+++ b/spec/lib/api/openid_connect/token_endpoint_spec.rb
@@ -5,7 +5,7 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
o_auth_application: client, user: bob, redirect_uri: "http://localhost:3000/", scopes: ["openid"])
}
let!(:code) { auth.create_code }
- let!(:client_with_specific_id) { FactoryGirl.create(:o_auth_application_with_ppid_with_specific_id) }
+ let!(:client_with_specific_id) { FactoryGirl.create(:o_auth_application_with_ppid) }
let!(:auth_with_specific_id) do
client_with_specific_id.client_id = "14d692cd53d9c1a9f46fd69e0e57443e"
client_with_specific_id.jwks = File.read(jwks_file_path)
@@ -19,9 +19,9 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
describe "the authorization code grant type" do
context "when the authorization code is valid" do
before do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
client_id: client.client_id, client_secret: client.client_secret,
- redirect_uri: "http://localhost:3000/", code: code
+ redirect_uri: "http://localhost:3000/", code: code}
end
it "should return a valid id token" do
@@ -53,26 +53,26 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
it "should not allow code to be reused" do
auth.reload
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
client_id: client.client_id, client_secret: client.client_secret,
- redirect_uri: "http://localhost:3000/", code: code
+ redirect_uri: "http://localhost:3000/", code: code}
expect(JSON.parse(response.body)["error"]).to eq("invalid_grant")
end
it "should not allow a nil code" do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
client_id: client.client_id, client_secret: client.client_secret,
- redirect_uri: "http://localhost:3000/", code: nil
+ redirect_uri: "http://localhost:3000/", code: nil}
expect(JSON.parse(response.body)["error"]).to eq("invalid_request")
end
end
context "when the authorization code is valid with jwt bearer" do
before do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
redirect_uri: "http://localhost:3000/", code: code_with_specific_id,
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
- client_assertion: File.read(valid_client_assertion_path)
+ client_assertion: File.read(valid_client_assertion_path)}
end
it "should return a valid id token" do
@@ -97,27 +97,27 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
it "should not allow code to be reused" do
auth_with_specific_id.reload
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
client_id: client.client_id, client_secret: client.client_secret,
- redirect_uri: "http://localhost:3000/", code: code_with_specific_id
+ redirect_uri: "http://localhost:3000/", code: code_with_specific_id}
expect(JSON.parse(response.body)["error"]).to eq("invalid_grant")
end
end
context "when the authorization code is not valid" do
it "should return an invalid grant error" do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
- client_id: client.client_id, client_secret: client.client_secret, code: "123456"
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
+ client_id: client.client_id, client_secret: client.client_secret, code: "123456"}
expect(response.body).to include "invalid_grant"
end
end
context "when the client assertion is in an invalid format" do
before do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
redirect_uri: "http://localhost:3000/", code: code_with_specific_id,
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
- client_assertion: "invalid_client_assertion.random"
+ client_assertion: "invalid_client_assertion.random"}
end
it "should return an error" do
@@ -127,10 +127,10 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
context "when the client assertion is not matching with jwks keys" do
before do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
redirect_uri: "http://localhost:3000/", code: code_with_specific_id,
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
- client_assertion: File.read(client_assertion_with_tampered_sig_path)
+ client_assertion: File.read(client_assertion_with_tampered_sig_path)}
end
it "should return an error" do
@@ -140,10 +140,10 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
context "when kid doesn't exist in jwks keys" do
before do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
redirect_uri: "http://localhost:3000/", code: code_with_specific_id,
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
- client_assertion: File.read(client_assertion_with_nonexistent_kid_path)
+ client_assertion: File.read(client_assertion_with_nonexistent_kid_path)}
end
it "should return an error" do
@@ -153,18 +153,18 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
context "when the client is unregistered" do
it "should return an error" do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code", code: auth.refresh_token,
- client_id: SecureRandom.hex(16).to_s, client_secret: client.client_secret
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code", code: auth.refresh_token,
+ client_id: SecureRandom.hex(16).to_s, client_secret: client.client_secret}
expect(response.body).to include "invalid_client"
end
end
context "when the client is unregistered with jwks keys" do
before do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
redirect_uri: "http://localhost:3000/", code: code_with_specific_id,
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
- client_assertion: File.read(client_assertion_with_nonexistent_client_id_path)
+ client_assertion: File.read(client_assertion_with_nonexistent_client_id_path)}
end
it "should return an error" do
@@ -174,16 +174,16 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
context "when the code field is missing" do
it "should return an invalid request error" do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code",
- client_id: client.client_id, client_secret: client.client_secret
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code",
+ client_id: client.client_id, client_secret: client.client_secret}
expect(response.body).to include "invalid_request"
end
end
context "when the client_secret doesn't match" do
it "should return an invalid client error" do
- post api_openid_connect_access_tokens_path, grant_type: "authorization_code", code: auth.refresh_token,
- client_id: client.client_id, client_secret: "client.client_secret"
+ post api_openid_connect_access_tokens_path, params: {grant_type: "authorization_code", code: auth.refresh_token,
+ client_id: client.client_id, client_secret: "client.client_secret"}
expect(response.body).to include "invalid_client"
end
end
@@ -191,8 +191,8 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
describe "an unsupported grant type" do
it "should return an unsupported grant type error" do
- post api_openid_connect_access_tokens_path, grant_type: "noexistgrant", username: "bob",
- password: "bluepin7", client_id: client.client_id, client_secret: client.client_secret, scope: "read"
+ post api_openid_connect_access_tokens_path, params: {grant_type: "noexistgrant", username: "bob",
+ password: "bluepin7", client_id: client.client_id, client_secret: client.client_secret, scope: "read"}
expect(response.body).to include "unsupported_grant_type"
end
end
@@ -200,8 +200,8 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
describe "the refresh token grant type" do
context "when the refresh token is valid" do
it "should return an access token" do
- post api_openid_connect_access_tokens_path, grant_type: "refresh_token",
- client_id: client.client_id, client_secret: client.client_secret, refresh_token: auth.refresh_token
+ post api_openid_connect_access_tokens_path, params: {grant_type: "refresh_token",
+ client_id: client.client_id, client_secret: client.client_secret, refresh_token: auth.refresh_token}
json = JSON.parse(response.body)
expect(response.body).to include "expires_in"
expect(json["access_token"].length).to eq(64)
@@ -211,32 +211,34 @@ describe Api::OpenidConnect::TokenEndpoint, type: :request do
context "when the refresh token is not valid" do
it "should return an invalid grant error" do
- post api_openid_connect_access_tokens_path, grant_type: "refresh_token",
- client_id: client.client_id, client_secret: client.client_secret, refresh_token: "123456"
+ post api_openid_connect_access_tokens_path, params: {grant_type: "refresh_token",
+ client_id: client.client_id, client_secret: client.client_secret, refresh_token: "123456"}
expect(response.body).to include "invalid_grant"
end
end
context "when the client is unregistered" do
it "should return an error" do
- post api_openid_connect_access_tokens_path, grant_type: "refresh_token", refresh_token: auth.refresh_token,
- client_id: SecureRandom.hex(16).to_s, client_secret: client.client_secret
+ post api_openid_connect_access_tokens_path, params: {grant_type: "refresh_token",
+ refresh_token: auth.refresh_token,
+ client_id: SecureRandom.hex(16).to_s, client_secret: client.client_secret}
expect(response.body).to include "invalid_client"
end
end
context "when the refresh_token field is missing" do
it "should return an invalid request error" do
- post api_openid_connect_access_tokens_path, grant_type: "refresh_token",
- client_id: client.client_id, client_secret: client.client_secret
+ post api_openid_connect_access_tokens_path, params: {grant_type: "refresh_token",
+ client_id: client.client_id, client_secret: client.client_secret}
expect(response.body).to include "'refresh_token' required"
end
end
context "when the client_secret doesn't match" do
it "should return an invalid client error" do
- post api_openid_connect_access_tokens_path, grant_type: "refresh_token", refresh_token: auth.refresh_token,
- client_id: client.client_id, client_secret: "client.client_secret"
+ post api_openid_connect_access_tokens_path, params: {grant_type: "refresh_token",
+ refresh_token: auth.refresh_token,
+ client_id: client.client_id, client_secret: "client.client_secret"}
expect(response.body).to include "invalid_client"
end
end
diff --git a/spec/lib/stream/person_spec.rb b/spec/lib/stream/person_spec.rb
index b5cd7422b..2c44377bc 100644
--- a/spec/lib/stream/person_spec.rb
+++ b/spec/lib/stream/person_spec.rb
@@ -32,7 +32,7 @@ describe Stream::Person do
end
posts = posts.reverse.slice(0..14)
- fetched_posts = fetched_posts.slice(0..14)
+ fetched_posts = fetched_posts.first(15)
expect(fetched_posts).to eq(posts)
end
diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb
index 1f9318519..aabad41dc 100644
--- a/spec/models/contact_spec.rb
+++ b/spec/models/contact_spec.rb
@@ -20,12 +20,12 @@ describe Contact, type: :model do
it "requires a user" do
contact.valid?
- expect(contact.errors.full_messages).to include "User can't be blank"
+ expect(contact.errors.full_messages).to include "User must exist"
end
it "requires a person" do
contact.valid?
- expect(contact.errors.full_messages).to include "Person can't be blank"
+ expect(contact.errors.full_messages).to include "Person must exist"
end
it "validates uniqueness" do
@@ -161,7 +161,6 @@ describe Contact, type: :model do
describe "#contacts" do
before do
bob.aspects.create(name: "next")
- bob.aspects(true)
@original_aspect = bob.aspects.where(name: "generic").first
@new_aspect = bob.aspects.where(name: "next").first
diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb
index fe3eadfe3..0742ffa50 100644
--- a/spec/models/location_spec.rb
+++ b/spec/models/location_spec.rb
@@ -1,12 +1,14 @@
-describe Location, :type => :model do
- describe 'before validation' do
- it 'should create new location when it has coordinates' do
- location = Location.new(coordinates:'1,2')
+describe Location, type: :model do
+ describe "before validation" do
+ let(:status) { FactoryGirl.create(:status_message) }
+
+ it "should create new location when it has coordinates" do
+ location = Location.new(coordinates: "1,2", status_message: status)
expect(location.save).to be true
end
- it 'should not create new location when it does not have coordinates' do
- location = Location.new()
+ it "should not create new location when it does not have coordinates" do
+ location = Location.new(status_message: status)
expect(location.save).to be false
end
end
diff --git a/spec/models/pod_spec.rb b/spec/models/pod_spec.rb
index 730f240e3..99e860c0b 100644
--- a/spec/models/pod_spec.rb
+++ b/spec/models/pod_spec.rb
@@ -142,6 +142,7 @@ describe Pod, type: :model do
before do
@pod = FactoryGirl.create(:pod)
@result = double("result")
+ @now = Time.zone.now
allow(@result).to receive(:rt) { 123 }
allow(@result).to receive(:software_version) { "diaspora a.b.c.d" }
@@ -158,7 +159,7 @@ describe Pod, type: :model do
expect(@pod.status).to eq("no_errors")
expect(@pod.offline?).to be_falsy
expect(@pod.response_time).to eq(123)
- expect(@pod.checked_at).to be_within(1.second).of Time.zone.now
+ expect(@pod.checked_at).to be_within(1.second).of @now
end
it "resets the scheduled_check flag" do
@@ -177,7 +178,7 @@ describe Pod, type: :model do
@pod.test_connection!
expect(@pod.offline?).to be_truthy
- expect(@pod.offline_since).to be_within(1.second).of Time.zone.now
+ expect(@pod.offline_since).to be_within(1.second).of @now
end
it "preserves the original offline timestamp" do
@@ -185,13 +186,12 @@ describe Pod, type: :model do
expect(@result).to receive(:error).at_least(:once) { ConnectionTester::NetFailure.new }
@pod.test_connection!
- now = Time.zone.now
- expect(@pod.offline_since).to be_within(1.second).of now
+ expect(@pod.offline_since).to be_within(1.second).of @now
Timecop.travel(Time.zone.today + 30.days) do
@pod.test_connection!
- expect(@pod.offline_since).to be_within(1.second).of now
- expect(Time.zone.now).to be_within(1.day).of(now + 30.days)
+ expect(@pod.offline_since).to be_within(1.second).of @now
+ expect(Time.zone.now).to be_within(1.day).of(@now + 30.days)
end
end
end
@@ -215,19 +215,22 @@ describe Pod, type: :model do
end
it "handles a failed status" do
+ now = Time.zone.now
+
pod.status = :unknown_error
pod.update_offline_since
expect(pod.offline?).to be_truthy
- expect(pod.offline_since).to be_within(1.second).of Time.zone.now
+ expect(pod.offline_since).to be_within(1.second).of now
end
it "preserves the original offline timestamp" do
+ now = Time.zone.now
+
pod.status = :unknown_error
pod.update_offline_since
pod.save
- now = Time.zone.now
expect(pod.offline_since).to be_within(1.second).of now
Timecop.travel(Time.zone.today + 30.days) do
diff --git a/spec/models/poll_participation_spec.rb b/spec/models/poll_participation_spec.rb
index 65730481b..677da69f0 100644
--- a/spec/models/poll_participation_spec.rb
+++ b/spec/models/poll_participation_spec.rb
@@ -1,25 +1,25 @@
describe PollParticipation, type: :model do
+ let(:status) { bob.post(:status_message, text: "hello", to: bob.aspects.first.id) }
+ let(:poll) { Poll.new(question: "Who is in charge?") }
+
before do
- @alices_aspect = alice.aspects.first
- @status = bob.post(:status_message, :text => "hello", :to => bob.aspects.first.id)
- @poll = Poll.new(:question => 'Who is in charge?')
- @poll.poll_answers.build(:answer => "a")
- @poll.poll_answers.build(:answer => "b")
- @status.poll = @poll
+ poll.poll_answers.build(answer: "a").poll = poll
+ poll.poll_answers.build(answer: "b").poll = poll
+ status.poll = poll
end
describe 'validation' do
it 'forbids multiple participations in the same poll' do
expect {
2.times do |run|
- bob.participate_in_poll!(@status, @poll.poll_answers.first)
+ bob.participate_in_poll!(status, poll.poll_answers.first)
end
}.to raise_error ActiveRecord::RecordInvalid
end
it 'allows a one time participation in a poll' do
expect {
- bob.participate_in_poll!(@status, @poll.poll_answers.first)
+ bob.participate_in_poll!(status, poll.poll_answers.first)
}.to_not raise_error
end
end
@@ -38,6 +38,6 @@ describe PollParticipation, type: :model do
let(:remote_object_on_local_parent) {
FactoryGirl.create(:poll_participation, poll_answer: local_parent.poll.poll_answers.first, author: remote_raphael)
}
- let(:relayable) { PollParticipation::Generator.new(alice, @status, @poll.poll_answers.first).build }
+ let(:relayable) { PollParticipation::Generator.new(alice, status, poll.poll_answers.first).build }
end
end
diff --git a/spec/models/poll_spec.rb b/spec/models/poll_spec.rb
index 30fd872bb..f18eb4fab 100644
--- a/spec/models/poll_spec.rb
+++ b/spec/models/poll_spec.rb
@@ -1,24 +1,23 @@
-describe Poll, :type => :model do
- before do
- @poll = Poll.new(:question => "What do you think about apples?")
- end
+describe Poll, type: :model do
+ let(:status) { FactoryGirl.create(:status_message) }
+ let(:poll) { Poll.new(question: "What do you think about apples?", status_message: status) }
- describe 'validation' do
- it 'should not create a poll when it has less than two answers' do
- @poll.poll_answers.build(:answer => '1')
- expect(@poll).not_to be_valid
+ describe "validation" do
+ it "should not create a poll when it has less than two answers" do
+ poll.poll_answers.build(answer: "1").poll = poll
+ expect(poll).not_to be_valid
end
- it 'should create a poll when it has more than two answers' do
- @poll.poll_answers.build(:answer => '1')
- @poll.poll_answers.build(:answer => '2')
- expect(@poll).to be_valid
+ it "should create a poll when it has more than two answers" do
+ poll.poll_answers.build(answer: "1").poll = poll
+ poll.poll_answers.build(answer: "2").poll = poll
+ expect(poll).to be_valid
end
- it 'should not create a poll when question in blank' do
- @poll.question = ' '
- @poll.valid?
- expect(@poll.errors).to have_key(:question)
+ it "should not create a poll when question in blank" do
+ poll.question = " "
+ poll.valid?
+ expect(poll.errors).to have_key(:question)
end
end
end
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index 550fdc74d..fdfc1f4b4 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -65,12 +65,12 @@ describe Post, :type => :model do
it 'calls includes_for_a_stream' do
expect(Post).to receive(:includes_for_a_stream)
- Post.for_a_stream(double, double)
+ Post.for_a_stream(Time.zone.now, "created_at")
end
it 'calls excluding_blocks if a user is present' do
expect(Post).to receive(:excluding_blocks).with(alice).and_return(Post)
- Post.for_a_stream(double, double, alice)
+ Post.for_a_stream(Time.zone.now, "created_at", alice)
end
end
@@ -168,7 +168,7 @@ describe Post, :type => :model do
it "returns them in reverse creation order" do
posts = Post.for_visible_shareable_sql(Time.now + 1, "created_at")
expect(posts.first.text).to eq("second")
- expect(posts.at(1).text).to eq("first")
+ expect(posts.second.text).to eq("first")
expect(posts.last.text).to eq("alice - 5")
end
end
diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb
index 4d245f7fd..8b6b5ab53 100644
--- a/spec/models/profile_spec.rb
+++ b/spec/models/profile_spec.rb
@@ -269,30 +269,6 @@ describe Profile, :type => :model do
it_should_behave_like 'it is taggable'
end
- describe '#formatted_birthday' do
- before do
- @profile = FactoryGirl.build(:profile)
- @profile_hash = { 'year' => '2000', 'month' => '01', 'day' => '01' }
- @profile.date = @profile_hash
- end
-
- it 'returns a formatted date' do
- expect(@profile.formatted_birthday).to eq("January 1, 2000")
- end
-
- it 'removes nil year birthdays' do
- @profile_hash.delete('year')
- @profile.date = @profile_hash
- expect(@profile.formatted_birthday).to eq('January 1')
- end
-
- it 'retuns nil if no birthday is set' do
- @profile.date = {}
- expect(@profile.formatted_birthday).to eq(nil)
- end
-
- end
-
describe "#tombstone!" do
before do
@profile = bob.person.profile
diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb
index 97b4424d1..dad31a04d 100644
--- a/spec/models/role_spec.rb
+++ b/spec/models/role_spec.rb
@@ -6,7 +6,12 @@ describe Role do
let!(:moderator_role) { moderator.roles.create(name: "moderator") }
describe "validations" do
- it { should validate_presence_of(:person) }
+ it "validates the presence of the person" do
+ role = Role.new(name: "admin")
+ role.valid?
+ expect(role.errors.full_messages).to include "Person must exist"
+ end
+
it { should validate_uniqueness_of(:name).scoped_to(:person_id) }
it { should validate_inclusion_of(:name).in_array(%w(admin spotlight moderator)) }
end
diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb
index 718f49ba3..d7632958e 100644
--- a/spec/models/status_message_spec.rb
+++ b/spec/models/status_message_spec.rb
@@ -193,7 +193,7 @@ describe StatusMessage, type: :model do
it "should queue a GatherOembedData if it includes a link" do
status_message
- expect(Workers::GatherOEmbedData).to receive(:perform_async).with(instance_of(Fixnum), instance_of(String))
+ expect(Workers::GatherOEmbedData).to receive(:perform_async).with(kind_of(Integer), instance_of(String))
status_message.save
end
@@ -214,7 +214,7 @@ describe StatusMessage, type: :model do
it "should queue a GatherOpenGraphData if it includes a link" do
status_message
- expect(Workers::GatherOpenGraphData).to receive(:perform_async).with(instance_of(Fixnum), instance_of(String))
+ expect(Workers::GatherOpenGraphData).to receive(:perform_async).with(kind_of(Integer), instance_of(String))
status_message.save
end
diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb
index 40ef55ce6..2d6d53f9d 100644
--- a/spec/models/user/connecting_spec.rb
+++ b/spec/models/user/connecting_spec.rb
@@ -21,7 +21,7 @@ describe User::Connecting, type: :model do
expect {
eve.disconnected_by(alice.person)
- }.to change(eve.contacts(true), :count).by(-1)
+ }.to change(eve.contacts, :count).by(-1)
end
it "does not remove contact if disconnect twice" do
@@ -31,7 +31,7 @@ describe User::Connecting, type: :model do
expect {
bob.disconnected_by(alice.person)
bob.disconnected_by(alice.person)
- }.not_to change(bob.contacts(true), :count)
+ }.not_to change(bob.contacts, :count)
contact.reload
expect(contact).not_to be_sharing
@@ -50,7 +50,7 @@ describe User::Connecting, type: :model do
it "removes a contacts receiving flag" do
expect(bob.contacts.find_by(person_id: alice.person.id)).to be_receiving
bob.disconnect(bob.contact_for(alice.person))
- expect(bob.contacts(true).find_by(person_id: alice.person.id)).not_to be_receiving
+ expect(bob.contacts.reload.find_by(person_id: alice.person.id)).not_to be_receiving
end
it "removes contact if not sharing" do
@@ -58,7 +58,7 @@ describe User::Connecting, type: :model do
expect {
alice.disconnect(contact)
- }.to change(alice.contacts(true), :count).by(-1)
+ }.to change(alice.contacts, :count).by(-1)
end
it "does not remove contact if disconnect twice" do
@@ -68,7 +68,7 @@ describe User::Connecting, type: :model do
expect {
alice.disconnect(contact)
alice.disconnect(contact)
- }.not_to change(bob.contacts(true), :count)
+ }.not_to change(bob.contacts, :count)
contact.reload
expect(contact).not_to be_receiving
@@ -100,7 +100,7 @@ describe User::Connecting, type: :model do
expect {
alice.disconnect(contact)
- }.to change(contact.aspects(true), :count).from(2).to(0)
+ }.to change(contact.aspects, :count).from(2).to(0)
end
end
end
diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb
index 83226b16a..dd24509ed 100644
--- a/spec/models/user/posting_spec.rb
+++ b/spec/models/user/posting_spec.rb
@@ -10,18 +10,17 @@ describe User, :type => :model do
describe '#add_to_streams' do
before do
- @params = {:text => "hey", :to => [@aspect.id, @aspect1.id]}
- @post = alice.build_post(:status_message, @params)
+ @post = alice.build_post(:status_message, text: "hey")
@post.save
- @aspect_ids = @params[:to]
+ @aspect_ids = [@aspect.id, @aspect1.id]
@aspects = alice.aspects_from_ids(@aspect_ids)
end
it 'saves post into visible post ids' do
expect {
alice.add_to_streams(@post, @aspects)
- }.to change{alice.visible_shareables(Post, :by_members_of => @aspects).length}.by(1)
- expect(alice.visible_shareables(Post, :by_members_of => @aspects)).to include @post
+ }.to change { alice.visible_shareables(Post, by_members_of: @aspect_ids).length }.by(1)
+ expect(alice.visible_shareables(Post, by_members_of: @aspect_ids)).to include @post
end
it 'saves post into each aspect in aspect_ids' do
diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb
index 471f2e32e..18ea07dfd 100644
--- a/spec/models/user/querying_spec.rb
+++ b/spec/models/user/querying_spec.rb
@@ -72,7 +72,7 @@ describe User::Querying, :type => :model do
end
it "does not pull back hidden posts" do
- @status.share_visibilities(Post).where(user_id: alice.id).first.update_attributes(hidden: true)
+ @status.share_visibilities.where(user_id: alice.id).first.update_attributes(hidden: true)
expect(alice.visible_shareable_ids(Post).include?(@status.id)).to be false
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 719129c78..7032dac82 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1078,7 +1078,7 @@ describe User, :type => :model do
end
it "#flags user for removal" do
- remove_at = Time.now+5.days
+ remove_at = Time.now.change(usec: 0).utc + 5.days
@user.flag_for_removal(remove_at)
expect(@user.remove_after).to eq(remove_at)
end
diff --git a/spec/presenters/o_embed_presenter_spec.rb b/spec/presenters/o_embed_presenter_spec.rb
index 9a14a5e7a..55c19a80e 100644
--- a/spec/presenters/o_embed_presenter_spec.rb
+++ b/spec/presenters/o_embed_presenter_spec.rb
@@ -17,7 +17,7 @@ describe OEmbedPresenter do
describe '#iframe_html' do
it 'passes the height options to post_iframe_url' do
- expect(@oembed).to receive(:post_iframe_url).with(instance_of(Fixnum), instance_of(Hash))
+ expect(@oembed).to receive(:post_iframe_url).with(kind_of(Integer), instance_of(Hash))
@oembed.iframe_html
end
end
@@ -31,4 +31,4 @@ describe OEmbedPresenter do
expect(OEmbedPresenter.id_from_url('http://localhost:400/p/1')).to eq("1")
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/serializers/notification_serializer_spec.rb b/spec/serializers/notification_serializer_spec.rb
index 8f9a20a3c..156dc5ee5 100644
--- a/spec/serializers/notification_serializer_spec.rb
+++ b/spec/serializers/notification_serializer_spec.rb
@@ -3,7 +3,7 @@ describe NotificationSerializer do
before do
allow(notifications_controller).to receive(:current_user).and_return(notification.recipient)
- notifications_controller.request = ActionController::TestRequest.new(host: AppConfig.pod_uri)
+ notifications_controller.request = ActionDispatch::TestRequest.new(host: AppConfig.pod_uri)
end
let(:notification) { FactoryGirl.create(:notification) }
diff --git a/spec/services/post_service_spec.rb b/spec/services/post_service_spec.rb
index 28dfae6c1..5dd889b72 100644
--- a/spec/services/post_service_spec.rb
+++ b/spec/services/post_service_spec.rb
@@ -299,7 +299,7 @@ describe PostService do
include_context "with a current user's friend"
it "returns mention suggestions in the correct order" do
- result = post_service.mentionable_in_comment(post.id, "Ro")
+ result = post_service.mentionable_in_comment(post.id, "Ro").to_a
expect(result.size).to be > 7
# participants: post author, comments, likers
expect(result[0..4]).to eq([post_author, commenter1, commenter2, liker1, liker2])
@@ -396,8 +396,10 @@ describe PostService do
end
it "calls Person.limit" do
- expect_any_instance_of(Person::ActiveRecord_Relation).to receive(:limit).with(15).and_call_original
- post_service.mentionable_in_comment(post.id, "whatever")
+ 16.times {
+ FactoryGirl.create(:comment, author: FactoryGirl.create(:person, first_name: "Ro#{r_str}"), post: post)
+ }
+ expect(post_service.mentionable_in_comment(post.id, "Ro").length).to eq(15)
end
it "contains a constraint on a current user" do
diff --git a/spec/shared_behaviors/taggable.rb b/spec/shared_behaviors/taggable.rb
index e7a61fb5f..d6accd6a4 100644
--- a/spec/shared_behaviors/taggable.rb
+++ b/spec/shared_behaviors/taggable.rb
@@ -30,7 +30,7 @@ shared_examples_for "it is taggable" do
it "supports non-ascii characters" do
tag_list.each do |tag|
- expect(@object.tags(true).map(&:name)).to include(tag)
+ expect(@object.tags.reload.map(&:name)).to include(tag)
end
end
diff --git a/spec/workers/send_private_spec.rb b/spec/workers/send_private_spec.rb
index 92765c0a2..e3d9a99bc 100644
--- a/spec/workers/send_private_spec.rb
+++ b/spec/workers/send_private_spec.rb
@@ -23,7 +23,7 @@ describe Workers::SendPrivate do
sender_id, obj_str, targets
).and_return(failing_targets)
expect(Workers::SendPrivate).to receive(:perform_in).with(
- kind_of(Fixnum), sender_id, obj_str, failing_targets, 1
+ kind_of(Integer), sender_id, obj_str, failing_targets, 1
)
Workers::SendPrivate.new.perform(sender_id, obj_str, targets)
diff --git a/spec/workers/send_public_spec.rb b/spec/workers/send_public_spec.rb
index bf34c6501..4f87ddb33 100644
--- a/spec/workers/send_public_spec.rb
+++ b/spec/workers/send_public_spec.rb
@@ -19,7 +19,7 @@ describe Workers::SendPublic do
sender_id, obj_str, urls, xml
).and_return(failing_urls)
expect(Workers::SendPublic).to receive(:perform_in).with(
- kind_of(Fixnum), sender_id, obj_str, failing_urls, xml, 1
+ kind_of(Integer), sender_id, obj_str, failing_urls, xml, 1
)
Workers::SendPublic.new.perform(sender_id, obj_str, urls, xml)