parent
42eeecba3f
commit
71fe24096c
@ -0,0 +1,7 @@ |
|||||||
|
class Mention < ActiveRecord::Base |
||||||
|
belongs_to :account, inverse_of: :mentions |
||||||
|
belongs_to :status, inverse_of: :mentions |
||||||
|
|
||||||
|
validates :account, :status, presence: true |
||||||
|
validates :account, uniqueness: { scope: :status } |
||||||
|
end |
@ -0,0 +1,33 @@ |
|||||||
|
class ProcessMentionsService < BaseService |
||||||
|
# Scan status for mentions and fetch remote mentioned users, create |
||||||
|
# local mention pointers, send Salmon notifications to mentioned |
||||||
|
# remote users |
||||||
|
# @param [Status] status |
||||||
|
def call(status) |
||||||
|
status.text.scan(Account::MENTION_RE).each do |match| |
||||||
|
username, domain = match.first.split('@') |
||||||
|
local_account = Account.find_by(username: username, domain: domain) |
||||||
|
|
||||||
|
if local_account.nil? |
||||||
|
local_account = follow_remote_account_service.("acct:#{match.first}") |
||||||
|
end |
||||||
|
|
||||||
|
local_account.mentions.first_or_create(status: status) |
||||||
|
end |
||||||
|
|
||||||
|
status.mentions.each do |mentioned_account| |
||||||
|
next if mentioned_account.local? |
||||||
|
send_interaction_service.(status.stream_entry, mentioned_account) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def follow_remote_account_service |
||||||
|
@follow_remote_account_service ||= FollowRemoteAccountService.new |
||||||
|
end |
||||||
|
|
||||||
|
def send_interaction_service |
||||||
|
@send_interaction_service ||= SendInteractionService.new |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,12 @@ |
|||||||
|
class CreateMentions < ActiveRecord::Migration |
||||||
|
def change |
||||||
|
create_table :mentions do |t| |
||||||
|
t.integer :account_id |
||||||
|
t.integer :status_id |
||||||
|
|
||||||
|
t.timestamps null: false |
||||||
|
end |
||||||
|
|
||||||
|
add_index :mentions, [:account_id, :status_id], unique: true |
||||||
|
end |
||||||
|
end |
@ -1,5 +1,11 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe AtomController, type: :controller do |
RSpec.describe AtomController, type: :controller do |
||||||
|
describe 'GET #user_stream' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe 'GET #entry' do |
||||||
|
pending |
||||||
|
end |
||||||
end |
end |
||||||
|
@ -1,5 +1,7 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe HomeController, type: :controller do |
RSpec.describe HomeController, type: :controller do |
||||||
|
describe 'GET #index' do |
||||||
|
pending |
||||||
|
end |
||||||
end |
end |
||||||
|
@ -1,12 +1,11 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe ProfileController, type: :controller do |
RSpec.describe ProfileController, type: :controller do |
||||||
|
describe 'GET #show' do |
||||||
describe "GET #show" do |
pending |
||||||
it "returns http success" do |
|
||||||
get :show |
|
||||||
expect(response).to have_http_status(:success) |
|
||||||
end |
|
||||||
end |
end |
||||||
|
|
||||||
|
describe 'GET #entry' do |
||||||
|
pending |
||||||
|
end |
||||||
end |
end |
||||||
|
@ -1,5 +1,11 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe XrdController, type: :controller do |
RSpec.describe XrdController, type: :controller do |
||||||
|
describe 'GET #host_meta' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe 'GET #webfinger' do |
||||||
|
pending |
||||||
|
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,15 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes |
||||||
|
# the RoutingHelper. For example: |
||||||
|
# |
||||||
|
# describe RoutingHelper 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 RoutingHelper, type: :helper do |
||||||
|
pending "add some examples to (or delete) #{__FILE__}" |
||||||
|
end |
@ -1,5 +1,47 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe Account, type: :model do |
RSpec.describe Account, type: :model do |
||||||
pending "add some examples to (or delete) #{__FILE__}" |
describe '#follow!' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#unfollow!' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#following?' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#local?' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#acct' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#subscribed?' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#keypair' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#subscription' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#object_type' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#title' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#content' do |
||||||
|
pending |
||||||
|
end |
||||||
end |
end |
||||||
|
@ -1,5 +1,31 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe Favourite, type: :model do |
RSpec.describe Favourite, type: :model do |
||||||
pending "add some examples to (or delete) #{__FILE__}" |
describe '#verb' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#title' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#content' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#object_type' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#target' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#mentions' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#thread' do |
||||||
|
pending |
||||||
|
end |
||||||
end |
end |
||||||
|
@ -1,5 +1,27 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe Follow, type: :model do |
RSpec.describe Follow, type: :model do |
||||||
pending "add some examples to (or delete) #{__FILE__}" |
describe '#verb' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#title' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#content' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#object_type' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#target' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#mentions' do |
||||||
|
pending |
||||||
|
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe Mention, type: :model do |
||||||
|
|
||||||
|
end |
@ -1,5 +1,35 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe Status, type: :model do |
RSpec.describe Status, type: :model do |
||||||
pending "add some examples to (or delete) #{__FILE__}" |
describe '#local?' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#reblog?' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#reply?' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#mentions' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#verb' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#object_type' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#title' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#target' do |
||||||
|
pending |
||||||
|
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,11 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe StreamEntry, type: :model do |
||||||
|
describe '#targeted?' do |
||||||
|
pending |
||||||
|
end |
||||||
|
|
||||||
|
describe '#threaded?' do |
||||||
|
pending |
||||||
|
end |
||||||
|
end |
@ -1,5 +0,0 @@ |
|||||||
require 'rails_helper' |
|
||||||
|
|
||||||
RSpec.describe Stream, type: :model do |
|
||||||
pending "add some examples to (or delete) #{__FILE__}" |
|
||||||
end |
|
@ -1,5 +1,5 @@ |
|||||||
require 'rails_helper' |
require 'rails_helper' |
||||||
|
|
||||||
RSpec.describe User, type: :model do |
RSpec.describe User, type: :model do |
||||||
pending "add some examples to (or delete) #{__FILE__}" |
|
||||||
end |
end |
||||||
|
@ -0,0 +1,16 @@ |
|||||||
|
ENV['RAILS_ENV'] ||= 'test' |
||||||
|
require File.expand_path('../../config/environment', __FILE__) |
||||||
|
|
||||||
|
abort("The Rails environment is running in production mode!") if Rails.env.production? |
||||||
|
|
||||||
|
require 'spec_helper' |
||||||
|
require 'rspec/rails' |
||||||
|
|
||||||
|
ActiveRecord::Migration.maintain_test_schema! |
||||||
|
|
||||||
|
RSpec.configure do |config| |
||||||
|
config.fixture_path = "#{::Rails.root}/spec/fixtures" |
||||||
|
config.use_transactional_fixtures = true |
||||||
|
config.infer_spec_type_from_file_location! |
||||||
|
config.filter_rails_from_backtrace! |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe FetchFeedService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe FollowRemoteAccountService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe FollowService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe PostStatusService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe ProcessFeedService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe ProcessInteractionService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe ProcessMentionsService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe ReblogService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe SendInteractionService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe SetupLocalAccountService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe UnfollowService do |
||||||
|
pending |
||||||
|
end |
@ -0,0 +1,15 @@ |
|||||||
|
require 'simplecov' |
||||||
|
|
||||||
|
SimpleCov.start 'rails' do |
||||||
|
add_group "Services", "app/services" |
||||||
|
end |
||||||
|
|
||||||
|
RSpec.configure do |config| |
||||||
|
config.expect_with :rspec do |expectations| |
||||||
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true |
||||||
|
end |
||||||
|
|
||||||
|
config.mock_with :rspec do |mocks| |
||||||
|
mocks.verify_partial_doubles = true |
||||||
|
end |
||||||
|
end |
@ -1,5 +0,0 @@ |
|||||||
require 'rails_helper' |
|
||||||
|
|
||||||
RSpec.describe "profile/show.html.haml", type: :view do |
|
||||||
pending "add some examples to (or delete) #{__FILE__}" |
|
||||||
end |
|
Loading…
Reference in new issue