simplify FanOutOnWriteService, add /api/accounts/lookup methodmaster
parent
bf08d46e58
commit
9d55529318
@ -0,0 +1,3 @@ |
|||||||
|
# Place all the behaviors and hooks related to the matching controller here. |
||||||
|
# All this logic will automatically be available in application.js. |
||||||
|
# You can use CoffeeScript in this file: http://coffeescript.org/ |
@ -0,0 +1,11 @@ |
|||||||
|
class Api::Accounts::LookupController < ApplicationController |
||||||
|
def index |
||||||
|
@accounts = Account.where(domain: nil).where(username: lookup_params) |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def lookup_params |
||||||
|
(params[:usernames] || '').split(',').map(&:strip) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,2 @@ |
|||||||
|
module Api::Accounts::LookupHelper |
||||||
|
end |
@ -1,6 +1,8 @@ |
|||||||
class BaseService |
class BaseService |
||||||
include RoutingHelper |
|
||||||
include ActionView::Helpers::TextHelper |
include ActionView::Helpers::TextHelper |
||||||
|
include ActionView::Helpers::SanitizeHelper |
||||||
|
|
||||||
|
include RoutingHelper |
||||||
include ApplicationHelper |
include ApplicationHelper |
||||||
include AtomBuilderHelper |
include AtomBuilderHelper |
||||||
end |
end |
||||||
|
@ -0,0 +1,2 @@ |
|||||||
|
collection @accounts |
||||||
|
extends('api/accounts/show') |
@ -0,0 +1,22 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe Api::Accounts::LookupController, type: :controller do |
||||||
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) } |
||||||
|
let(:token) { double acceptable?: true, resource_owner_id: user.id } |
||||||
|
|
||||||
|
before do |
||||||
|
allow(controller).to receive(:doorkeeper_token) { token } |
||||||
|
end |
||||||
|
|
||||||
|
describe 'GET #index' do |
||||||
|
before do |
||||||
|
Fabricate(:account, username: 'alice') |
||||||
|
Fabricate(:account, username: 'bob') |
||||||
|
get :index, usernames: 'alice,bob' |
||||||
|
end |
||||||
|
|
||||||
|
it 'returns http success' do |
||||||
|
expect(response).to have_http_status(:success) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,15 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes |
||||||
|
# the Api::Accounts::LookupHelper. For example: |
||||||
|
# |
||||||
|
# describe Api::Accounts::LookupHelper do |
||||||
|
# describe "string concat" do |
||||||
|
# it "concats two strings with spaces" do |
||||||
|
# expect(helper.concat_strings("this","that")).to eq("this that") |
||||||
|
# end |
||||||
|
# end |
||||||
|
# end |
||||||
|
RSpec.describe Api::Accounts::LookupHelper, type: :helper do |
||||||
|
pending "add some examples to (or delete) #{__FILE__}" |
||||||
|
end |
Loading…
Reference in new issue