From 73be8f38c115c279e3d3961b98bd2b82b9706b05 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 6 Dec 2018 17:36:11 +0100 Subject: Add profile directory (#9427) Fix #5578 --- spec/fabricators/account_tag_stat_fabricator.rb | 3 +++ spec/models/account_tag_stat_spec.rb | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 spec/fabricators/account_tag_stat_fabricator.rb create mode 100644 spec/models/account_tag_stat_spec.rb (limited to 'spec') diff --git a/spec/fabricators/account_tag_stat_fabricator.rb b/spec/fabricators/account_tag_stat_fabricator.rb new file mode 100644 index 000000000..9edb550be --- /dev/null +++ b/spec/fabricators/account_tag_stat_fabricator.rb @@ -0,0 +1,3 @@ +Fabricator(:account_tag_stat) do + accounts_count "" +end diff --git a/spec/models/account_tag_stat_spec.rb b/spec/models/account_tag_stat_spec.rb new file mode 100644 index 000000000..f1ebc5578 --- /dev/null +++ b/spec/models/account_tag_stat_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe AccountTagStat, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end -- cgit From 51cbd045dab531725b448311ea52d0aec215a8f8 Mon Sep 17 00:00:00 2001 From: ysksn Date: Sat, 8 Dec 2018 00:37:56 +0900 Subject: Add specs for AccountTagStat model (#9452) --- spec/models/account_tag_stat_spec.rb | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/account_tag_stat_spec.rb b/spec/models/account_tag_stat_spec.rb index f1ebc5578..6d3057f35 100644 --- a/spec/models/account_tag_stat_spec.rb +++ b/spec/models/account_tag_stat_spec.rb @@ -1,5 +1,38 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountTagStat, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + key = 'accounts_count' + let(:account_tag_stat) { Fabricate(:tag).account_tag_stat } + + describe '#increment_count!' do + it 'calls #update' do + args = { key => account_tag_stat.public_send(key) + 1 } + expect(account_tag_stat).to receive(:update).with(args) + account_tag_stat.increment_count!(key) + end + + it 'increments value by 1' do + expect do + account_tag_stat.increment_count!(key) + end.to change { account_tag_stat.accounts_count }.by(1) + end + end + + describe '#decrement_count!' do + it 'calls #update' do + args = { key => [account_tag_stat.public_send(key) - 1, 0].max } + expect(account_tag_stat).to receive(:update).with(args) + account_tag_stat.decrement_count!(key) + end + + it 'decrements value by 1' do + account_tag_stat.update(key => 1) + + expect do + account_tag_stat.decrement_count!(key) + end.to change { account_tag_stat.accounts_count }.by(-1) + end + end end -- cgit From 57bb62d5cfe1b269ccfc82c0d2fd73fbf1252a3d Mon Sep 17 00:00:00 2001 From: ysksn Date: Sat, 8 Dec 2018 00:38:50 +0900 Subject: Remove pending spec (#9454) Since dots are not allowed in username, this spec is no longer needed. --- spec/validators/unique_username_validator_spec.rb | 8 -------- 1 file changed, 8 deletions(-) (limited to 'spec') diff --git a/spec/validators/unique_username_validator_spec.rb b/spec/validators/unique_username_validator_spec.rb index b9d773bed..c2e2eedf4 100644 --- a/spec/validators/unique_username_validator_spec.rb +++ b/spec/validators/unique_username_validator_spec.rb @@ -15,14 +15,6 @@ describe UniqueUsernameValidator do expect(account).to be_valid end - it 'adds an error when the username is already used with ignoring dots' do - pending 'allowing dots in username is still in development' - Fabricate(:account, username: 'abcd.ef') - account = double(username: 'ab.cdef', persisted?: false, errors: double(add: nil)) - subject.validate(account) - expect(account.errors).to have_received(:add) - end - it 'adds an error when the username is already used with ignoring cases' do Fabricate(:account, username: 'ABCdef') account = double(username: 'abcDEF', persisted?: false, errors: double(add: nil)) -- cgit From 88b3eed16f9ecabfc81b81d1af3a2e10b0f68517 Mon Sep 17 00:00:00 2001 From: ysksn Date: Sat, 8 Dec 2018 00:39:20 +0900 Subject: Add specs for Admin::AccountModerationNotesHelper (#9455) --- .../admin/account_moderation_notes_helper_spec.rb | 62 ++++++++++++++++++---- 1 file changed, 51 insertions(+), 11 deletions(-) (limited to 'spec') diff --git a/spec/helpers/admin/account_moderation_notes_helper_spec.rb b/spec/helpers/admin/account_moderation_notes_helper_spec.rb index 01b60c851..c07f6c4b8 100644 --- a/spec/helpers/admin/account_moderation_notes_helper_spec.rb +++ b/spec/helpers/admin/account_moderation_notes_helper_spec.rb @@ -1,15 +1,55 @@ +# frozen_string_literal: true + require 'rails_helper' -# Specs in this file have access to a helper object that includes -# the Admin::AccountModerationNotesHelper. For example: -# -# describe Admin::AccountModerationNotesHelper 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 Admin::AccountModerationNotesHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" + include StreamEntriesHelper + + describe '#admin_account_link_to' do + context 'account is nil' do + let(:account) { nil } + + it 'returns nil' do + expect(helper.admin_account_link_to(account)).to be_nil + end + end + + context 'with account' do + let(:account) { Fabricate(:account) } + + it 'calls #link_to' do + expect(helper).to receive(:link_to).with( + admin_account_path(account.id), + class: name_tag_classes(account), + title: account.acct + ) + + helper.admin_account_link_to(account) + end + end + end + + describe '#admin_account_inline_link_to' do + context 'account is nil' do + let(:account) { nil } + + it 'returns nil' do + expect(helper.admin_account_inline_link_to(account)).to be_nil + end + end + + context 'with account' do + let(:account) { Fabricate(:account) } + + it 'calls #link_to' do + expect(helper).to receive(:link_to).with( + admin_account_path(account.id), + class: name_tag_classes(account, true), + title: account.acct + ) + + helper.admin_account_inline_link_to(account) + end + end + end end -- cgit From d3547fa00580a03d1687316d56c32f407c0d9fe6 Mon Sep 17 00:00:00 2001 From: ysksn Date: Sat, 8 Dec 2018 00:40:01 +0900 Subject: Add specs for ActivityPub::InboxesController (#9456) --- .../activitypub/inboxes_controller_spec.rb | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/controllers/activitypub/inboxes_controller_spec.rb b/spec/controllers/activitypub/inboxes_controller_spec.rb index 5c12fea7d..4055d9342 100644 --- a/spec/controllers/activitypub/inboxes_controller_spec.rb +++ b/spec/controllers/activitypub/inboxes_controller_spec.rb @@ -1,7 +1,29 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::InboxesController, type: :controller do describe 'POST #create' do - pending + context 'if signed_request_account' do + it 'returns 202' do + allow(controller).to receive(:signed_request_account) do + Fabricate(:account) + end + + post :create + expect(response).to have_http_status(202) + end + end + + context 'not signed_request_account' do + it 'returns 401' do + allow(controller).to receive(:signed_request_account) do + false + end + + post :create + expect(response).to have_http_status(401) + end + end end end -- cgit From dfd123d5b3f2bef19833cff8beb3ba2edb17c68a Mon Sep 17 00:00:00 2001 From: ysksn Date: Sat, 8 Dec 2018 00:53:55 +0900 Subject: Remove pending spec (#9453) --- spec/models/account_pin_spec.rb | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 spec/models/account_pin_spec.rb (limited to 'spec') diff --git a/spec/models/account_pin_spec.rb b/spec/models/account_pin_spec.rb deleted file mode 100644 index 4f226b127..000000000 --- a/spec/models/account_pin_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe AccountPin, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end -- cgit