mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-02 02:44:29 -04:00
Add a small page for a Flickr connect pop-up to end on
/authentications/connected says whether Flickr got connected and closes itself. It has no site header or footer, as it appears in a small window. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d9d3ebb9bd
commit
9d33a0feaf
4 files changed
+63
-1
No files matched your search
@@ -4,6 +4,7 @@ require './lib/actions/oauth_signup_action'
|
||||
class AuthenticationsController < ApplicationController
|
||||
before_action :authenticate_member!
|
||||
load_and_authorize_resource
|
||||
skip_load_and_authorize_resource only: :connected
|
||||
|
||||
# POST /authentications
|
||||
def create
|
||||
@@ -31,6 +32,14 @@ class AuthenticationsController < ApplicationController
|
||||
redirect_to request.env['omniauth.origin'] || edit_member_registration_path
|
||||
end
|
||||
|
||||
# Where the pop-up that connects an account from a dialog ends up (see
|
||||
# AddPhotoModal): it says how it went and closes itself. The dialog notices the
|
||||
# connection by asking the server, so it doesn't depend on this page.
|
||||
def connected
|
||||
@connected = current_member.auth('flickr').present?
|
||||
render layout: false
|
||||
end
|
||||
|
||||
# DELETE /authentications/1
|
||||
def destroy
|
||||
@authentication.destroy
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
!!! 5
|
||||
%html{lang: 'en'}
|
||||
%head
|
||||
%meta{charset: 'utf-8'}
|
||||
%meta{name: 'viewport', content: 'width=device-width, initial-scale=1'}
|
||||
%title= @connected ? 'Flickr connected' : 'Flickr not connected'
|
||||
= stylesheet_link_tag 'application'
|
||||
%body.p-4
|
||||
- if @connected
|
||||
%h1 Flickr is connected
|
||||
%p You can close this window and carry on choosing a photo.
|
||||
- else
|
||||
%h1 Flickr was not connected
|
||||
%p You can close this window and try again.
|
||||
%button.btn{type: 'button', onclick: 'window.close()'} Close this window
|
||||
:javascript
|
||||
window.close();
|
||||
+3
-1
@@ -21,7 +21,9 @@ Rails.application.routes.draw do
|
||||
end
|
||||
match '/members/:id/finish_signup' => 'members#finish_signup', via: %i(get patch), as: :finish_signup
|
||||
|
||||
resources :authentications, only: %i(create destroy)
|
||||
resources :authentications, only: %i(create destroy) do
|
||||
get :connected, on: :collection
|
||||
end
|
||||
|
||||
get "home/index"
|
||||
get '/community-gardens', to: 'home#community_gardens'
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
# The page a Flickr connect pop-up (opened from the add photo dialog) ends on.
|
||||
describe 'GET /authentications/connected' do
|
||||
include Devise::Test::IntegrationHelpers
|
||||
|
||||
let(:member) { create(:member) }
|
||||
|
||||
before { sign_in member }
|
||||
|
||||
it 'says Flickr is connected once the member has connected it' do
|
||||
create(:flickr_authentication, member: member)
|
||||
|
||||
get connected_authentications_path
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include('Flickr is connected')
|
||||
expect(response.body).to include('window.close()')
|
||||
end
|
||||
|
||||
it 'says it was not connected when the member has not' do
|
||||
get connected_authentications_path
|
||||
|
||||
expect(response.body).to include('Flickr was not connected')
|
||||
end
|
||||
|
||||
it 'is not a full page of the site: no header or footer to look at in a small window' do
|
||||
get connected_authentications_path
|
||||
|
||||
expect(response.body).not_to include('page-footer')
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user