diff --git a/Gemfile b/Gemfile index 1fdbf6993979b9d3f5631b40885eb1b422a4814e..5d0feec7de94e6ba13a32534f95b2488ca41deca 100644 --- a/Gemfile +++ b/Gemfile @@ -23,9 +23,9 @@ gem "json-schema", "2.6.2" # Authentication -gem "devise", "3.5.6" +gem "devise", "4.2.0" gem "devise_lastseenable", "0.0.6" -gem "devise-token_authenticatable", "0.4.6" +gem "devise-token_authenticatable", "0.5.2" # Captcha diff --git a/Gemfile.lock b/Gemfile.lock index 36bf1920289badd6abadb1ab38bbb95b6cd9a1c3..740994baef8479dc9d92deb5cc5654697f11cfc9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -165,15 +165,14 @@ GEM railties (>= 3, < 5) cucumber-wire (0.0.1) database_cleaner (1.5.3) - devise (3.5.6) + devise (4.2.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) + railties (>= 4.1.0, < 5.1) responders - thread_safe (~> 0.1) warden (~> 1.2.3) - devise-token_authenticatable (0.4.6) - devise (>= 3.5.2, < 4.0.0) + devise-token_authenticatable (0.5.2) + devise (>= 4.0.0, < 4.3.0) devise_lastseenable (0.0.6) devise rails (>= 3.0.4) @@ -927,8 +926,8 @@ DEPENDENCIES cucumber-api-steps (= 0.13) cucumber-rails (= 1.4.3) database_cleaner (= 1.5.3) - devise (= 3.5.6) - devise-token_authenticatable (= 0.4.6) + devise (= 4.2.0) + devise-token_authenticatable (= 0.5.2) devise_lastseenable (= 0.0.6) diaspora-prosody-config (= 0.0.5) diaspora_federation-rails (= 0.1.3) diff --git a/config/locales/devise/devise.en.yml b/config/locales/devise/devise.en.yml index a75999662da776950c9ca16d9ceeea7feeb8adeb..45f35a2386f5dc0f68781a11914ae9d979760106 100644 --- a/config/locales/devise/devise.en.yml +++ b/config/locales/devise/devise.en.yml @@ -1,88 +1,129 @@ en: - errors: - messages: - not_found: "not found" - already_confirmed: "was already confirmed" - not_locked: "was not locked" - devise: - failure: - unauthenticated: 'You need to sign in or sign up before continuing.' - unconfirmed: 'You have to confirm your account before continuing.' - locked: 'Your account is locked.' - not_found_in_database: 'Invalid email or password.' - invalid: 'Invalid username or password.' - invalid_token: 'Invalid authentication token.' - timeout: 'Your session expired, please sign in again to continue.' - inactive: 'Your account was not activated yet.' - sessions: - new: - login: 'Log in' - username: 'Username' - password: 'Password' - sign_in: 'Sign in' - remember_me: "Remember me" - modern_browsers: 'only supports modern browsers.' - signed_in: 'Signed in successfully.' - signed_out: 'Signed out successfully.' - passwords: - send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' - updated: 'Your password was changed successfully. You are now signed in.' - edit: - change_password: "Change my password" - new_password: "New password" - confirm_password: "Confirm password" - new: - forgot_password: "Forgot your password?" - no_account: 'No account with this email exists' - reset_password: "Reset password" - email: "Email address" - send_password_instructions: "Send me reset password instructions" confirmations: - send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' - confirmed: 'Your account was successfully confirmed. You are now signed in.' - new: - resend_confirmation: "Resend confirmation instructions" - registrations: - signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.' - updated: 'You updated your account successfully.' - destroyed: 'Bye! Your account was successfully deleted. We hope to see you again soon.' - unlocks: - send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' - unlocked: 'Your account was successfully unlocked. You are now signed in.' + confirmed: Your email address has been successfully confirmed. + send_instructions: You will receive an email with instructions for how to confirm + your email address in a few minutes. + send_paranoid_instructions: If your email address exists in our database, you + will receive an email with instructions for how to confirm your email address + in a few minutes. new: - resend_unlock: "Resend unlock instructions" - invitations: - send_instructions: 'Your invitation has been sent.' - invitation_token_invalid: 'Our apologies! That invitation token is not valid.' - updated: 'Your password was set successfully. You are now signed in.' + resend_confirmation: Resend confirmation instructions + failure: + already_authenticated: You are already signed in. + inactive: Your account is not activated yet. + invalid: Invalid %{authentication_keys} or password. + locked: Your account is locked. + last_attempt: You have one more attempt before your account is locked. + not_found_in_database: Invalid %{authentication_keys} or password. + timeout: Your session expired. Please sign in again to continue. + unauthenticated: You need to sign in or sign up before continuing. + unconfirmed: You have to confirm your email address before continuing. + invalid_token: Invalid authentication token. mailer: - welcome: "Welcome %{email}!" - hello: "Hello %{email}!" confirmation_instructions: - subject: 'Confirmation instructions' - you_can_confirm: "You can confirm your account through the link below:" - confirm: "Confirm my account" + subject: Confirmation instructions + you_can_confirm: 'You can confirm your account through the link below:' + confirm: Confirm my account reset_password_instructions: - subject: 'Reset password instructions' - someone_requested: "Someone has requested a link to change your password. If it was you, you can do this through the link below." - change: "Change my password" - wont_change: "Your password won't change until you access the link above and create a new one." - ignore: "If you didn't request this, please ignore this email." + subject: Reset password instructions + someone_requested: Someone has requested a link to change your password. If + it was you, you can do this through the link below. + change: Change my password + wont_change: Your password won't change until you access the link above and + create a new one. + ignore: If you didn't request this, please ignore this email. unlock_instructions: - subject: 'Unlock instructions' - account_locked: "Your account has been locked due to an excessive number of unsuccessful sign in attempts." - click_to_unlock: "Click the link below to unlock your account:" - unlock: "Unlock my account" + subject: Unlock instructions + account_locked: Your account has been locked due to an excessive number of + unsuccessful sign in attempts. + click_to_unlock: 'Click the link below to unlock your account:' + unlock: Unlock my account + password_change: + subject: Password Changed + welcome: Welcome %{email}! + hello: Hello %{email}! inviter: has_invited_you: "%{name}" have_invited_you: "%{names} have invited you to join diaspora*" - accept_at: "at %{url}, you can accept it through the link below." + accept_at: at %{url}, you can accept it through the link below. + omniauth_callbacks: + failure: Could not authenticate you from %{kind} because "%{reason}". + success: Successfully authenticated from %{kind} account. + passwords: + no_token: You can't access this page without coming from a password reset email. + If you do come from a password reset email, please make sure you used the + full URL provided. + send_instructions: You will receive an email with instructions on how to reset + your password in a few minutes. + send_paranoid_instructions: If your email address exists in our database, you + will receive a password recovery link at your email address in a few minutes. + updated: Your password has been changed successfully. You are now signed in. + updated_not_active: Your password has been changed successfully. + edit: + change_password: Change my password + new_password: New password + confirm_password: Confirm password + new: + forgot_password: Forgot your password? + no_account: No account with this email exists + reset_password: Reset password + email: Email address + send_password_instructions: Send me reset password instructions + registrations: + destroyed: Bye! Your account was successfully deleted. We hope to see you again + soon. + signed_up: You have signed up successfully. If enabled, a confirmation was sent + to your e-mail. + signed_up_but_inactive: You have signed up successfully. However, we could not + sign you in because your account is not yet activated. + signed_up_but_locked: You have signed up successfully. However, we could not + sign you in because your account is locked. + signed_up_but_unconfirmed: A message with a confirmation link has been sent + to your email address. Please follow the link to activate your account. + update_needs_confirmation: You updated your account successfully, but we need + to verify your new email address. Please check your email and follow the confirm + link to confirm your new email address. + updated: Your account has been updated successfully. + sessions: + signed_in: Signed in successfully. + signed_out: Signed out successfully. + already_signed_out: Signed out successfully. + new: + login: Log in + username: Username + password: Password + sign_in: Sign in + remember_me: Remember me + modern_browsers: only supports modern browsers. + unlocks: + send_instructions: You will receive an email with instructions for how to unlock + your account in a few minutes. + send_paranoid_instructions: If your account exists, you will receive an email + with instructions for how to unlock it in a few minutes. + unlocked: Your account has been unlocked successfully. Please sign in to continue. + new: + resend_unlock: Resend unlock instructions + invitations: + send_instructions: Your invitation has been sent. + invitation_token_invalid: Our apologies! That invitation token is not valid. + updated: Your password was set successfully. You are now signed in. shared: links: - sign_in: 'Sign in' - sign_up: 'Create account' - sign_up_closed: 'Open signups are closed at this time.' - forgot_your_password: 'Forgot your password?' - receive_confirmation: "Didn't receive confirmation instructions?" - receive_unlock: "Didn't receive unlock instructions?" + sign_in: Sign in + sign_up: Create account + sign_up_closed: Open signups are closed at this time. + forgot_your_password: Forgot your password? + receive_confirmation: Didn't receive confirmation instructions? + receive_unlock: Didn't receive unlock instructions? + errors: + messages: + already_confirmed: was already confirmed, please try signing in + confirmation_period_expired: needs to be confirmed within %{period}, please + request a new one + expired: has expired, please request a new one + not_found: not found + not_locked: was not locked + not_saved: + one: '1 error prohibited this %{resource} from being saved:' + other: "%{count} errors prohibited this %{resource} from being saved:" diff --git a/spec/controllers/admin/pods_controller_spec.rb b/spec/controllers/admin/pods_controller_spec.rb index b5741b1ba5a9a180b9b2429d4f54711043157e1e..cd4e198b3cee983ca5350bcd7977a4f2383f6e60 100644 --- a/spec/controllers/admin/pods_controller_spec.rb +++ b/spec/controllers/admin/pods_controller_spec.rb @@ -6,7 +6,7 @@ describe Admin::PodsController, type: :controller do @user = FactoryGirl.create :user Role.add_admin(@user.person) - sign_in :user, @user + sign_in @user, scope: :user end describe "#index" do diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index c2653685378946d28dc28a66503004427689f762..d9f9dd9110492dd5de8dd3cd881a1ec8fc80d492 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -6,7 +6,7 @@ describe Admin::UsersController, :type => :controller do @user = FactoryGirl.create :user Role.add_admin(@user.person) - sign_in :user, @user + sign_in @user, scope: :user end describe '#close_account' do diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb index 5e2d5914ead2d9e3a6c12302dd56aba1f35f1200..e56fc5fb7dd9a68ec9de1213b1331818b4f2ea26 100644 --- a/spec/controllers/admins_controller_spec.rb +++ b/spec/controllers/admins_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe AdminsController, :type => :controller do before do @user = FactoryGirl.create :user - sign_in :user, @user + sign_in @user, scope: :user end describe '#user_search' do diff --git a/spec/controllers/api/openid_connect/authorizations_controller_spec.rb b/spec/controllers/api/openid_connect/authorizations_controller_spec.rb index 9448317d79b1bf36baa85898c492648003cc4d47..9a0631e63a74c97b2cfab6f76f1fb8121224c40a 100644 --- a/spec/controllers/api/openid_connect/authorizations_controller_spec.rb +++ b/spec/controllers/api/openid_connect/authorizations_controller_spec.rb @@ -6,7 +6,7 @@ describe Api::OpenidConnect::AuthorizationsController, type: :controller do let!(:client_with_multiple_redirects) { FactoryGirl.create(:o_auth_application_with_multiple_redirects) } before do - sign_in :user, alice + sign_in alice, scope: :user end describe "#new" do diff --git a/spec/controllers/api/openid_connect/user_applications_spec.rb b/spec/controllers/api/openid_connect/user_applications_spec.rb index 71c7dc7e31bab0d992dc55bd6422b465b5013583..588384159ce55199e64897d311c76fa89461f2c2 100644 --- a/spec/controllers/api/openid_connect/user_applications_spec.rb +++ b/spec/controllers/api/openid_connect/user_applications_spec.rb @@ -5,7 +5,7 @@ describe Api::OpenidConnect::UserApplicationsController, type: :controller do @app = FactoryGirl.create(:o_auth_application_with_xss) @user = FactoryGirl.create :user FactoryGirl.create :auth_with_read, user: @user, o_auth_application: @app - sign_in :user, @user + sign_in @user, scope: :user end context "when try to XSS" do diff --git a/spec/controllers/aspect_memberships_controller_spec.rb b/spec/controllers/aspect_memberships_controller_spec.rb index 848560381e275d6974854b2c30f18b79ceafb0fd..78c0adfd656db89d28e6ac71e633c478692517d1 100644 --- a/spec/controllers/aspect_memberships_controller_spec.rb +++ b/spec/controllers/aspect_memberships_controller_spec.rb @@ -13,7 +13,7 @@ describe AspectMembershipsController, type: :controller do @contact = alice.contact_for(bob.person) alice.getting_started = false alice.save - sign_in :user, alice + sign_in alice, scope: :user allow(@controller).to receive(:current_user).and_return(alice) request.env["HTTP_REFERER"] = "http://" + request.host end diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 779e510dee0f50f2078f64464f16043b10b949ca..c8f971ae10f7e4038b425c6be3fc1814bf5cb825 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -8,7 +8,7 @@ describe AspectsController, :type => :controller do before do alice.getting_started = false alice.save - sign_in :user, alice + sign_in alice, scope: :user @alices_aspect_1 = alice.aspects.where(:name => "generic").first @alices_aspect_2 = alice.aspects.create(:name => "another aspect") diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index bd9bb899fa508f70d5fdedda786fa5c2bcd56efd..39492d19198718c88cd9fcc3ac6d7fb2e238b6fd 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe CommentsController, :type => :controller do before do allow(@controller).to receive(:current_user).and_return(alice) - sign_in :user, alice + sign_in alice, scope: :user end describe '#create' do @@ -79,7 +79,7 @@ describe CommentsController, :type => :controller do context 'your post' do before do allow(@controller).to receive(:current_user).and_return(bob) - sign_in :user, bob + sign_in bob, scope: :user end it 'lets the user delete his comment' do diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 0f343e43b49f4e553da72e9c699613b7b233364b..27f9b9def179b0cf737e7506bdb4d89a22de1620 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe ContactsController, :type => :controller do before do - sign_in :user, bob + sign_in bob, scope: :user allow(@controller).to receive(:current_user).and_return(bob) end diff --git a/spec/controllers/conversation_visibilities_controller_spec.rb b/spec/controllers/conversation_visibilities_controller_spec.rb index 24d60addaf28fa33784930d8a2204073f2037aac..f9dc655bd2546068183620de5cacbaf2291c1d10 100644 --- a/spec/controllers/conversation_visibilities_controller_spec.rb +++ b/spec/controllers/conversation_visibilities_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe ConversationVisibilitiesController, :type => :controller do before do @user1 = alice - sign_in :user, @user1 + sign_in @user1, scope: :user hash = { :author => @user1.person, @@ -27,22 +27,22 @@ describe ConversationVisibilitiesController, :type => :controller do it 'does not let a user destroy a visibility that is not theirs' do user2 = eve - sign_in :user, user2 + sign_in user2, scope: :user expect { delete :destroy, :conversation_id => @conversation.id }.not_to change(ConversationVisibility, :count) end - + it 'returns "hidden"' do get :destroy, :conversation_id => @conversation.id expect(flash.notice).to include("hidden") end - + it 'returns "deleted" when last participant' do get :destroy, :conversation_id => @conversation.id sign_out :user - sign_in :user, bob + sign_in bob, scope: :user get :destroy, :conversation_id => @conversation.id expect(flash.notice).to include("deleted") end diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb index 0b02751283be78d9b369f6d80aa946fae65a4ef4..67c1da1262076495529377126362b3977cabe03c 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe ConversationsController, :type => :controller do before do - sign_in :user, alice + sign_in alice, scope: :user end describe '#new' do @@ -98,7 +98,7 @@ describe ConversationsController, :type => :controller do end it "does not let you access conversations where you are not a recipient" do - sign_in :user, eve + sign_in eve, scope: :user get :index, conversation_id: @conversations.first.id expect(assigns[:conversation]).to be_nil end diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb index c0a0bee6845a679aef4a2940e70057ad27ba26e0..06f9385fdd50552f4ac88a1aebc04279e7bf62a4 100644 --- a/spec/controllers/invitations_controller_spec.rb +++ b/spec/controllers/invitations_controller_spec.rb @@ -14,7 +14,7 @@ describe InvitationsController, :type => :controller do describe "#create" do before do - sign_in :user, @user + sign_in @user, scope: :user allow(@controller).to receive(:current_user).and_return(@user) @referer = 'http://test.host/cats/foo' request.env["HTTP_REFERER"] = @referer @@ -159,7 +159,7 @@ describe InvitationsController, :type => :controller do describe '#new' do it 'renders' do - sign_in :user, @user + sign_in @user, scope: :user get :new end end diff --git a/spec/controllers/jasmine_fixtures/admins_spec.rb b/spec/controllers/jasmine_fixtures/admins_spec.rb index 73086e9a3343ba4b0b33852fdb411b105384c2ed..af4784d221de2664fab9138d01f6bab0f123981b 100644 --- a/spec/controllers/jasmine_fixtures/admins_spec.rb +++ b/spec/controllers/jasmine_fixtures/admins_spec.rb @@ -5,7 +5,7 @@ describe AdminsController, type: :controller do before do @user = FactoryGirl.create :user Role.add_admin(@user.person) - sign_in :user, @user + sign_in @user, scope: :user end context "jasmine fixtures" do diff --git a/spec/controllers/jasmine_fixtures/aspects_spec.rb b/spec/controllers/jasmine_fixtures/aspects_spec.rb index a2539dc97df90e14e3e6b07201b48278ee9b5e47..f3ea2b5bab6454bb4a530fcaa540439670b3b863 100644 --- a/spec/controllers/jasmine_fixtures/aspects_spec.rb +++ b/spec/controllers/jasmine_fixtures/aspects_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe StreamsController, :type => :controller do describe '#aspects' do before do - sign_in :user, alice + sign_in alice, scope: :user @alices_aspect_2 = alice.aspects.create(:name => "another aspect") request.env["HTTP_REFERER"] = 'http://' + request.host diff --git a/spec/controllers/jasmine_fixtures/contacts_spec.rb b/spec/controllers/jasmine_fixtures/contacts_spec.rb index 11207e0f6f19a6f317eae4f4e64e640e27284366..261d3a88d69a16735d16c530ba59d82bc19af2b8 100644 --- a/spec/controllers/jasmine_fixtures/contacts_spec.rb +++ b/spec/controllers/jasmine_fixtures/contacts_spec.rb @@ -11,7 +11,7 @@ describe ContactsController, :type => :controller do @aspect = bob.aspects.create(:name => "another aspect") bob.share_with alice.person, @aspect bob.share_with eve.person, @aspect - sign_in :user, bob + sign_in bob, scope: :user end it "generates the aspects_manage fixture", :fixture => true do diff --git a/spec/controllers/jasmine_fixtures/conversations_spec.rb b/spec/controllers/jasmine_fixtures/conversations_spec.rb index b5d86e66c9a72b53002fbcf37026553456e8b8fd..4c4d317b7186155e6cc566317fa037a5d8fd1a8c 100644 --- a/spec/controllers/jasmine_fixtures/conversations_spec.rb +++ b/spec/controllers/jasmine_fixtures/conversations_spec.rb @@ -20,7 +20,7 @@ describe ConversationsController, :type => :controller do Message.create(:author => @person, :created_at => Time.now + 100, :text => "message", :conversation_id => @conv2.id) .increase_unread(alice) - sign_in :user, alice + sign_in alice, scope: :user end it "generates a jasmine fixture", :fixture => true do diff --git a/spec/controllers/jasmine_fixtures/notifications_spec.rb b/spec/controllers/jasmine_fixtures/notifications_spec.rb index 771d99ec549f7060e9cfd98c5c84a45efeef6def..75f95bc801689465ae95f0851d09e8f87e8eca50 100644 --- a/spec/controllers/jasmine_fixtures/notifications_spec.rb +++ b/spec/controllers/jasmine_fixtures/notifications_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe NotificationsController, :type => :controller do describe '#index' do before do - sign_in :user, alice + sign_in alice, scope: :user @post = FactoryGirl.create(:status_message) FactoryGirl.create(:notification, :recipient => alice, :target => @post) get :read_all diff --git a/spec/controllers/jasmine_fixtures/people_spec.rb b/spec/controllers/jasmine_fixtures/people_spec.rb index e251df4b4dfe754bf0693f87def038d6078f117b..eb387f06e724f726ad72bd3b52102a27e43fbcb8 100644 --- a/spec/controllers/jasmine_fixtures/people_spec.rb +++ b/spec/controllers/jasmine_fixtures/people_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe PeopleController, :type => :controller do describe '#index' do before do - sign_in :user, bob + sign_in bob, scope: :user end it "generates a jasmine fixture with no query", :fixture => true do diff --git a/spec/controllers/jasmine_fixtures/photos_spec.rb b/spec/controllers/jasmine_fixtures/photos_spec.rb index 79e6868ee5477c30e533538f6940109c8ee7ff2d..cde36c7b205b5f2bff4708525f47f1470a5e28db 100644 --- a/spec/controllers/jasmine_fixtures/photos_spec.rb +++ b/spec/controllers/jasmine_fixtures/photos_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe PhotosController, :type => :controller do before do @alices_photo = alice.post(:photo, :user_file => uploaded_photo, :to => alice.aspects.first.id, :public => false) - sign_in :user, alice + sign_in alice, scope: :user end describe '#index' do diff --git a/spec/controllers/jasmine_fixtures/status_messages_spec.rb b/spec/controllers/jasmine_fixtures/status_messages_spec.rb index 66730dfade0dfd7d7154e672e7aca6d670dee782..0787327fff2940fc699b81bd982582ea47627bec 100644 --- a/spec/controllers/jasmine_fixtures/status_messages_spec.rb +++ b/spec/controllers/jasmine_fixtures/status_messages_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe StatusMessagesController, :type => :controller do describe '#bookmarklet' do before do - sign_in :user, bob + sign_in bob, scope: :user end it "generates a jasmine fixture", :fixture => true do @@ -19,7 +19,7 @@ describe StatusMessagesController, :type => :controller do describe '#new' do before do - sign_in :user, alice + sign_in alice, scope: :user end it 'generates a jasmine fixture', :fixture => true do diff --git a/spec/controllers/jasmine_fixtures/streams_spec.rb b/spec/controllers/jasmine_fixtures/streams_spec.rb index 94e0cbb032137c8a686f404737f1f7ea6dddc7da..485343c186d2a9e4d4fd9b09977f37c3abc845be 100644 --- a/spec/controllers/jasmine_fixtures/streams_spec.rb +++ b/spec/controllers/jasmine_fixtures/streams_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe StreamsController, :type => :controller do describe '#multi' do before do - sign_in :user, alice + sign_in alice, scope: :user end it 'generates the stream_json fixture', :fixture => true do diff --git a/spec/controllers/jasmine_fixtures/users_spec.rb b/spec/controllers/jasmine_fixtures/users_spec.rb index 147f7bdee8a5c1395f58e046c05d30d756c3f7ae..9eb2e17b9e765f4f78254065ad22ad2ad02443df 100644 --- a/spec/controllers/jasmine_fixtures/users_spec.rb +++ b/spec/controllers/jasmine_fixtures/users_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" describe UsersController, type: :controller do before do - sign_in :user, alice + sign_in alice, scope: :user end describe "#getting_started" do diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 725c7f1a8217f30ff274cf642fb03f933723d2bb..066bdc01ae07383bee99dc0858f6adc995b50542 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -9,7 +9,7 @@ describe LikesController, :type => :controller do @alices_aspect = alice.aspects.where(:name => "generic").first @bobs_aspect = bob.aspects.where(:name => "generic").first - sign_in :user, alice + sign_in(alice, scope: :user) end [Comment, Post].each do |class_const| diff --git a/spec/controllers/messages_controller_spec.rb b/spec/controllers/messages_controller_spec.rb index 24129e19b02c6e9aa51a6d1c99322ea07dcfe03c..27e8bfe4fe132fadefcfe4133c8d953002f6c869 100644 --- a/spec/controllers/messages_controller_spec.rb +++ b/spec/controllers/messages_controller_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe MessagesController, :type => :controller do before do - sign_in :user, alice + sign_in(alice, scope: :user) end describe '#create' do diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 5bb68ccb01916fe3e9058ed3cc519760308dc295..b5e32bb9ef0541fcde1afc253df08ae3a4011859 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe NotificationsController, :type => :controller do before do - sign_in :user, alice + sign_in alice, scope: :user end describe '#update' do diff --git a/spec/controllers/participations_controller_spec.rb b/spec/controllers/participations_controller_spec.rb index 4262ae5805cdb5eca2b3b4774d1cfd62f21e441c..576c66a7cd87967f9ffcf512b82e7177c12f59fc 100644 --- a/spec/controllers/participations_controller_spec.rb +++ b/spec/controllers/participations_controller_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe ParticipationsController, :type => :controller do before do allow(@controller).to receive(:current_user).and_return(alice) - sign_in :user, alice + sign_in alice, scope: :user end describe '#create' do diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index 30794cc07ea7f10c7db40f0641c4af4710dc8aa6..45a55e28b3bef75f6f8578182c285894654fa306 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -5,8 +5,6 @@ require "spec_helper" describe Devise::PasswordsController, type: :controller do - include Devise::TestHelpers - before do @request.env["devise.mapping"] = Devise.mappings[:user] end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 675a321e817762e85ef2478bf7f1635776f3fc7e..8672b75479688d6ddc8d16ca2d2e7e62d7db0bd1 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -10,7 +10,7 @@ describe PeopleController, :type => :controller do before do @user = alice @aspect = @user.aspects.first - sign_in :user, @user + sign_in @user, scope: :user end describe '#index (search)' do @@ -315,7 +315,7 @@ describe PeopleController, :type => :controller do context "when the user is following the person" do before do sign_out :user - sign_in :user, peter + sign_in peter, scope: :user @person = alice.person end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 26ad7e13a18cdcac43c3bb55fb3b1ca117775440..5cad2566b2ccbb7dba880470501ea1c5776095aa 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -9,7 +9,7 @@ describe PhotosController, :type => :controller do @alices_photo = alice.post(:photo, :user_file => uploaded_photo, :to => alice.aspects.first.id, :public => false) @bobs_photo = bob.post(:photo, :user_file => uploaded_photo, :to => bob.aspects.first.id, :public => true) - sign_in :user, alice + sign_in alice, scope: :user request.env["HTTP_REFERER"] = '' end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 1c188ff138e433c864cd8f4b23ef5a2cac3ee132..a77d49d9c0ea2e3566c9b49dbe77f240b64e22bc 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -11,7 +11,7 @@ describe PostsController, type: :controller do context "user signed in" do context "given a post that the user is allowed to see" do before do - sign_in :user, alice + sign_in alice, scope: :user end it "succeeds" do @@ -50,7 +50,7 @@ describe PostsController, type: :controller do context "given a post that the user is not allowed to see" do before do - sign_in :user, eve + sign_in eve, scope: :user end it "returns a 404" do @@ -128,7 +128,7 @@ describe PostsController, type: :controller do context "post of another user" do it "will respond with a 403" do - sign_in :user, bob + sign_in bob, scope: :user delete :destroy, format: :json, id: post.id expect(response.body).to eq("You are not allowed to do that") @@ -136,7 +136,7 @@ describe PostsController, type: :controller do end it "will respond with a 404 if the post is not visible" do - sign_in :user, eve + sign_in eve, scope: :user expect { delete :destroy, format: :json, id: post.id diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index c32878c6ed3c36a6e2214cfe7a51b9e91aa23579..88b082d235aacbe081ad7ea757fe25d4badd4f5b 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe ProfilesController, :type => :controller do before do - sign_in :user, eve + sign_in eve, scope: :user end describe '#show' do diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 6866b712e5d88189d55f1fed6dc452181a42e35f..78f5afb20707c60af1d23745250186d9cf2accd1 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -4,9 +4,7 @@ require 'spec_helper' -describe RegistrationsController, :type => :controller do - include Devise::TestHelpers - +describe RegistrationsController, type: :controller do before do request.env["devise.mapping"] = Devise.mappings[:user] @valid_params = {:user => { diff --git a/spec/controllers/reshares_controller_spec.rb b/spec/controllers/reshares_controller_spec.rb index 5285927bd546e631889af0f800859c8274d5fece..cc4b7e9ecbf7a9311840b86b75d79724be4dfc50 100644 --- a/spec/controllers/reshares_controller_spec.rb +++ b/spec/controllers/reshares_controller_spec.rb @@ -18,7 +18,7 @@ describe ResharesController, :type => :controller do context 'with an authenticated user' do before do - sign_in :user, bob + sign_in(bob, scope: :user) allow(@controller).to receive(:current_user).and_return(bob) end diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index bc07db4ae131daeb96a07e61f5b16dbfbf859f20..58a62ba71bbe82f36da659fafeacbc17cb633715 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -4,7 +4,7 @@ describe SearchController, :type => :controller do before do @user = alice @aspect = @user.aspects.first - sign_in :user, @user + sign_in @user, scope: :user end describe 'query is a person' do @@ -23,7 +23,7 @@ describe SearchController, :type => :controller do get :search, :q => '#cats' expect(response).to redirect_to(tag_path('cats')) end - + it 'removes dots from the query' do get :search, :q => '#cat.s' expect(response).to redirect_to(tag_path('cats')) diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index d7bd50e92d5959cace3ef03d2afe9a4979b712d7..5c0c2f51fc77ec16dba9b36425ff0923c2a9ae20 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -14,7 +14,7 @@ describe ServicesController, :type => :controller do let(:user) { alice } before do - sign_in :user, user + sign_in user, scope: :user allow(@controller).to receive(:current_user).and_return(user) end @@ -75,11 +75,11 @@ describe ServicesController, :type => :controller do context 'when the access-level is read-only' do let(:header) { { 'x-access-level' => 'read' } } - let(:access_token) { double('access_token') } + let(:access_token) { double("access_token") } let(:extra) { {'extra' => { 'access_token' => access_token }} } let(:provider) { {'provider' => 'twitter'} } - before do + before do allow(access_token).to receive_message_chain(:response, :header).and_return header request.env['omniauth.auth'] = omniauth_auth.merge!( provider).merge!( extra ) end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 4ba846ed1ff77b47c6273f2d93c9220178705700..51e7361830d627fd3a90324292f7857f9455bd72 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -5,8 +5,6 @@ require "spec_helper" describe SessionsController, type: :controller do - include Devise::TestHelpers - let(:mock_access_token) { Object.new } before do @@ -34,7 +32,7 @@ describe SessionsController, type: :controller do describe "#destroy" do before do - sign_in :user, @user + sign_in @user, scope: :user end it "redirects to / for a non-mobile user" do delete :destroy @@ -51,7 +49,7 @@ describe SessionsController, type: :controller do describe "#reset_authentication_token" do context "for a logged in user" do before do - sign_in :user, @user + sign_in @user, scope: :user end it "succeeds" do diff --git a/spec/controllers/share_visibilities_controller_spec.rb b/spec/controllers/share_visibilities_controller_spec.rb index 5fe1bb11b79ff5e691d2b5e66f8bed0a5e9d356d..6215de699bdd639da0d95b9c29cc813da47d2576 100644 --- a/spec/controllers/share_visibilities_controller_spec.rb +++ b/spec/controllers/share_visibilities_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe ShareVisibilitiesController, :type => :controller do before do @status = alice.post(:status_message, :text => "hello", :to => alice.aspects.first) - sign_in :user, bob + sign_in(bob, scope: :user) end describe '#update' do diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index a045a7a065cc4e4ee881be568ddb8bbdb14ab18b..0c5ad604eb8a175d4c1efd86f324f09400135af8 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -9,7 +9,7 @@ describe StatusMessagesController, :type => :controller do @aspect1 = alice.aspects.first request.env["HTTP_REFERER"] = "" - sign_in :user, alice + sign_in alice, scope: :user allow(@controller).to receive(:current_user).and_return(alice) alice.reload end diff --git a/spec/controllers/tag_followings_controller_spec.rb b/spec/controllers/tag_followings_controller_spec.rb index 95ad774c4413a73d12f27658e0cc39f08cb50567..46546dd224bb0474c3a57ac3433ec684fb6cb24a 100644 --- a/spec/controllers/tag_followings_controller_spec.rb +++ b/spec/controllers/tag_followings_controller_spec.rb @@ -15,7 +15,7 @@ describe TagFollowingsController, type: :controller do end context "signed in" do before do - sign_in :user, alice + sign_in alice, scope: :user end it "redirects html requests" do diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 06ccdf6eab71edc96e7b4933a43f8a2efae8807e..ebcf401ffbf5c386e011fb9fc6e78fd13d131f4b 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe TagsController, :type => :controller do describe '#index (search)' do before do - sign_in :user, alice + sign_in alice, scope: :user bob.profile.tag_string = "#cats #diaspora #rad" bob.profile.build_tags bob.profile.save! @@ -38,7 +38,7 @@ describe TagsController, :type => :controller do describe '#show' do context 'tag with capital letters' do before do - sign_in :user, alice + sign_in alice, scope: :user end it 'redirect to the downcase tag uri' do @@ -67,7 +67,7 @@ describe TagsController, :type => :controller do context 'signed in' do before do - sign_in :user, alice + sign_in alice, scope: :user end it 'assigns a Stream::Tag object with the current_user' do diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index d28ad8088b3dbd429343736c5a9a170d91f77213..4fc1577bc98607fba9ed3db197f480a278038499 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -9,7 +9,7 @@ describe UsersController, :type => :controller do before do @user = alice - sign_in :user, @user + sign_in @user, scope: :user allow(@controller).to receive(:current_user).and_return(@user) end @@ -186,7 +186,7 @@ describe UsersController, :type => :controller do end it 'informs the user about failure' do - put(:update, :id => @user.id, :user => { :email => "my@newemailcom"}) + put(:update, 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 diff --git a/spec/helpers/interim_stream_hackiness_helper_spec.rb b/spec/helpers/interim_stream_hackiness_helper_spec.rb index c0cbb0ba576297f76c0b5c74e30f42dd35988bf7..31fcfc2e9ae7022ed8e7212780a4c3ae76d9da10 100644 --- a/spec/helpers/interim_stream_hackiness_helper_spec.rb +++ b/spec/helpers/interim_stream_hackiness_helper_spec.rb @@ -1,8 +1,9 @@ require 'spec_helper' -describe InterimStreamHackinessHelper, :type => :helper do - describe 'commenting_disabled?' do - include Devise::TestHelpers +describe InterimStreamHackinessHelper, type: :helper do + describe "commenting_disabled?" do + include Devise::Test::ControllerHelpers + before do sign_in alice def user_signed_in? diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index efcdfd081223a7ae4bcfaf8355170dcd94de764a..c67789bf6701b78a9b4fabb81e66fb895534bf2e 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" -describe UsersHelper, :type => :helper do - include Devise::TestHelpers +describe UsersHelper, type: :helper do + include Devise::Test::ControllerHelpers describe "#current_color_theme" do describe "if user is not signed in" do diff --git a/spec/integration/mentioning_spec.rb b/spec/integration/mentioning_spec.rb index 8d93ebd819746f48e53cb05e94564324242e1910..aa21b125ac7d3a070f29fda40347bdd24ff63c2e 100644 --- a/spec/integration/mentioning_spec.rb +++ b/spec/integration/mentioning_spec.rb @@ -1,5 +1,4 @@ require "spec_helper" -require "requests_helper" module MentioningSpecHelpers def default_aspect @@ -35,7 +34,7 @@ describe "mentioning", type: :request do @user3 = FactoryGirl.create :user @user1.share_with(@user2.person, default_aspect) - login @user1 + sign_in @user1 end # see: https://github.com/diaspora/diaspora/issues/4160 diff --git a/spec/integration/profile_spec.rb b/spec/integration/profile_spec.rb index 3c6a207931147a905baababad6df88bd6a1a4740..1e61cdb122a9a6c53353f3a1846575e3fea033d4 100644 --- a/spec/integration/profile_spec.rb +++ b/spec/integration/profile_spec.rb @@ -1,10 +1,9 @@ require "spec_helper" -require "requests_helper" describe PeopleController, type: :request do context "for the current user" do before do - login alice + sign_in alice end it "displays the publisher for user profile path" do @@ -37,7 +36,7 @@ describe PeopleController, type: :request do context "for another user" do before do - login bob + sign_in bob end it "doesn't display the publisher for user profile path" do diff --git a/spec/lib/i18n_interpolation_fallbacks_spec.rb b/spec/lib/i18n_interpolation_fallbacks_spec.rb index 436d5fa1ed607003989ba680c9685fca3ad0bb0a..a93fe1f59306e67f3a7f7f7ebd8dd52fef069e17 100644 --- a/spec/lib/i18n_interpolation_fallbacks_spec.rb +++ b/spec/lib/i18n_interpolation_fallbacks_spec.rb @@ -7,10 +7,12 @@ require 'spec_helper' describe "i18n interpolation fallbacks" do describe "when string does not require interpolation arguments" do it "works normally" do - expect(I18n.t('user.invalid', - :resource_name => "user", - :scope => "devise.failure", - :default => [:invalid, "invalid"])).to eq("Invalid username or password.") + expect( + I18n.t("user.already_authenticated", + resource_name: "user", + scope: "devise.failure", + default: [:already_authenticated, "already_authenticated"]) + ).to eq("You are already signed in.") end end describe "when string requires interpolation arguments" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9b551e95a94f01253d998908b2bb01ba58a1ea8d..eb37f8b9d4b6234f94e12387492e67fb6a303ca7 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -302,7 +302,7 @@ describe User, :type => :model do end it "requires a valid email address" do - alice.email = "somebody@anywhere" + alice.email = "somebodyanywhere" expect(alice).not_to be_valid end @@ -334,7 +334,7 @@ describe User, :type => :model do end it "requires a valid unconfirmed_email address" do - alice.unconfirmed_email = "somebody@anywhere" + alice.unconfirmed_email = "somebodyanywhere" expect(alice).not_to be_valid end end diff --git a/spec/requests_helper.rb b/spec/requests_helper.rb deleted file mode 100644 index fdae9a95da530103e43a1c054db2a268fc9a64fe..0000000000000000000000000000000000000000 --- a/spec/requests_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -include Warden::Test::Helpers - -def login(user) - login_as user, scope: :user -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a01b2d827cd09835ebc2a173ff1ce16c33862a08..9033d284285c3e42bd8cfdf45a0cfb17766ba66a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -93,7 +93,8 @@ support_files.each {|f| require f } require fixture_builder_file RSpec.configure do |config| - config.include Devise::TestHelpers, :type => :controller + config.include Devise::Test::ControllerHelpers, type: :controller + config.include Devise::Test::IntegrationHelpers, type: :request config.mock_with :rspec config.example_status_persistence_file_path = "tmp/rspec-persistance.txt"