diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c2dc6e4bfc..df1b4718ed 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -964,6 +964,7 @@ Rails/ThreeStateBooleanColumn: - 'db/migrate/20170209184350_add_reply_to_statuses.rb' - 'db/migrate/20170330163835_create_imports.rb' - 'db/migrate/20170905165803_add_local_to_statuses.rb' + - 'db/migrate/20171210213213_add_local_only_flag_to_statuses.rb' - 'db/migrate/20181203021853_add_discoverable_to_accounts.rb' - 'db/migrate/20190509164208_add_by_moderator_to_tombstone.rb' - 'db/migrate/20190805123746_add_capabilities_to_tags.rb' diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index 4c0e9b8580..0ee3a519b6 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -127,7 +127,7 @@ class Sanitize node = env[:node] rel = (node['rel'] || '').split & ['tag'] - rel += ['nofollow', 'noopener', 'noreferrer'] unless TagManager.instance.local_url?(node['href']) + rel += %w(nofollow noopener noreferrer) unless TagManager.instance.local_url?(node['href']) if rel.empty? node.remove_attribute('rel') diff --git a/spec/lib/advanced_text_formatter_spec.rb b/spec/lib/advanced_text_formatter_spec.rb index 8b27b56a15..f923852196 100644 --- a/spec/lib/advanced_text_formatter_spec.rb +++ b/spec/lib/advanced_text_formatter_spec.rb @@ -9,10 +9,10 @@ RSpec.describe AdvancedTextFormatter do let(:preloaded_accounts) { nil } let(:content_type) { 'text/markdown' } - context 'given a markdown source' do + context 'with a markdown source' do let(:content_type) { 'text/markdown' } - context 'given text containing plain text' do + context 'with text containing plain text' do let(:text) { 'text' } it 'paragraphizes the text' do @@ -20,7 +20,7 @@ RSpec.describe AdvancedTextFormatter do end end - context 'given text containing line feeds' do + context 'with text containing line feeds' do let(:text) { "line\nfeed" } it 'removes line feeds' do @@ -28,7 +28,7 @@ RSpec.describe AdvancedTextFormatter do end end - context 'given some inline code using backticks' do + context 'with some inline code using backticks' do let(:text) { 'test `foo` bar' } it 'formats code using ' do @@ -36,7 +36,7 @@ RSpec.describe AdvancedTextFormatter do end end - context 'given a block code' do + context 'with a block code' do let(:text) { "test\n\n```\nint main(void) {\n return 0; // https://joinmastodon.org/foo\n}\n```\n" } it 'formats code using
 and ' do
@@ -52,7 +52,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a link in inline code using backticks' do
+      context 'with a link in inline code using backticks' do
         let(:text) { 'test `https://foo.bar/bar` bar' }
 
         it 'does not rewrite the link' do
@@ -60,7 +60,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text with a local-domain mention' do
+      context 'with text with a local-domain mention' do
         let(:text) { 'foo https://cb6e6126.ngrok.io/about/more' }
 
         it 'creates a link' do
@@ -68,7 +68,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text containing linkable mentions' do
+      context 'with text containing linkable mentions' do
         let(:preloaded_accounts) { [Fabricate(:account, username: 'alice')] }
         let(:text) { '@alice' }
 
@@ -77,7 +77,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text containing unlinkable mentions' do
+      context 'with text containing unlinkable mentions' do
         let(:preloaded_accounts) { [] }
         let(:text) { '@alice' }
 
@@ -86,7 +86,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a stand-alone medium URL' do
+      context 'with a stand-alone medium URL' do
         let(:text) { 'https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4' }
 
         it 'matches the full URL' do
@@ -94,7 +94,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a stand-alone google URL' do
+      context 'with a stand-alone google URL' do
         let(:text) { 'http://google.com' }
 
         it 'matches the full URL' do
@@ -102,7 +102,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a stand-alone URL with a newer TLD' do
+      context 'with a stand-alone URL with a newer TLD' do
         let(:text) { 'http://example.gay' }
 
         it 'matches the full URL' do
@@ -110,7 +110,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a stand-alone IDN URL' do
+      context 'with a stand-alone IDN URL' do
         let(:text) { 'https://nic.みんな/' }
 
         it 'matches the full URL' do
@@ -122,7 +122,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a URL with a trailing period' do
+      context 'with a URL with a trailing period' do
         let(:text) { 'http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona. ' }
 
         it 'matches the full URL but not the period' do
@@ -130,7 +130,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a URL enclosed with parentheses' do
+      context 'with a URL enclosed with parentheses' do
         let(:text) { '(http://google.com/)' }
 
         it 'matches the full URL but not the parentheses' do
@@ -138,7 +138,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a URL with a trailing exclamation point' do
+      context 'with a URL with a trailing exclamation point' do
         let(:text) { 'http://www.google.com!' }
 
         it 'matches the full URL but not the exclamation point' do
@@ -146,7 +146,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a URL with a trailing single quote' do
+      context 'with a URL with a trailing single quote' do
         let(:text) { "http://www.google.com'" }
 
         it 'matches the full URL but not the single quote' do
@@ -155,7 +155,7 @@ RSpec.describe AdvancedTextFormatter do
       end
     end
 
-    context 'given a URL with a trailing angle bracket' do
+    context 'with a URL with a trailing angle bracket' do
       let(:text) { 'http://www.google.com>' }
 
       it 'matches the full URL but not the angle bracket' do
@@ -163,7 +163,7 @@ RSpec.describe AdvancedTextFormatter do
       end
     end
 
-    context 'given a URL with a query string' do
+    context 'with a URL with a query string' do
       context 'with escaped unicode character' do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=autolink' }
 
@@ -196,7 +196,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a URL with parentheses in it' do
+      context 'with a URL with parentheses in it' do
         let(:text) { 'https://en.wikipedia.org/wiki/Diaspora_(software)' }
 
         it 'matches the full URL' do
@@ -204,7 +204,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a URL in quotation marks' do
+      context 'with a URL in quotation marks' do
         let(:text) { '"https://example.com/"' }
 
         it 'does not match the quotation marks' do
@@ -212,7 +212,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a URL in angle brackets' do
+      context 'with a URL in angle brackets' do
         let(:text) { '' }
 
         it 'does not match the angle brackets' do
@@ -220,7 +220,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given a URL containing unsafe code (XSS attack, invisible part)' do
+      context 'with a URL containing unsafe code (XSS attack, invisible part)' do
         let(:text) { 'http://example.com/blahblahblahblah/a' }
 
         it 'does not include the HTML in the URL' do
@@ -232,7 +232,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text containing HTML code (script tag)' do
+      context 'with text containing HTML code (script tag)' do
         let(:text) { '' }
 
         it 'does not include a script tag' do
@@ -240,7 +240,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text containing HTML (XSS attack)' do
+      context 'with text containing HTML (XSS attack)' do
         let(:text) { %q{} }
 
         it 'does not include the javascript' do
@@ -248,7 +248,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given an invalid URL' do
+      context 'with an invalid URL' do
         let(:text) { 'http://www\.google\.com' }
 
         it 'outputs the raw URL' do
@@ -256,7 +256,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text containing a hashtag' do
+      context 'with text containing a hashtag' do
         let(:text)  { '#hashtag' }
 
         it 'creates a hashtag link' do
@@ -264,7 +264,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text containing a hashtag with Unicode chars' do
+      context 'with text containing a hashtag with Unicode chars' do
         let(:text)  { '#hashtagタグ' }
 
         it 'creates a hashtag link' do
@@ -272,7 +272,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text with a stand-alone xmpp: URI' do
+      context 'with text with a stand-alone xmpp: URI' do
         let(:text) { 'xmpp:user@instance.com' }
 
         it 'matches the full URI' do
@@ -280,7 +280,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text with an xmpp: URI with a query-string' do
+      context 'with text with an xmpp: URI with a query-string' do
         let(:text) { 'please join xmpp:muc@instance.com?join right now' }
 
         it 'matches the full URI' do
@@ -288,7 +288,7 @@ RSpec.describe AdvancedTextFormatter do
         end
       end
 
-      context 'given text containing a magnet: URI' do
+      context 'with text containing a magnet: URI' do
         let(:text) { 'wikipedia gives this example of a magnet uri: magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a' }
 
         it 'matches the full URI' do
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 27f2468461..3b612ded14 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -216,7 +216,7 @@ RSpec.describe Status do
         subject.text = "A toot #{subject.local_only_emoji}"
       end
 
-      context 'if the status originates from this instance' do
+      context 'when the status originates from this instance' do
         before do
           subject.account = local_account
         end
@@ -228,7 +228,7 @@ RSpec.describe Status do
         end
       end
 
-      context 'if the status is remote' do
+      context 'when the status is remote' do
         before do
           subject.account = remote_account
         end