mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
DEV: Make the first argument to the top-level describe a constant in specs
This commit is contained in:

committed by
Loïc Guitaut

parent
8b8cbe7905
commit
00b3f0e2c4
@ -7,7 +7,7 @@ GIT
|
|||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/discourse/rubocop-discourse.git
|
remote: https://github.com/discourse/rubocop-discourse.git
|
||||||
revision: 9642e65f3767e5fd1d4e1aec4b617179f4128909
|
revision: a5aea6e5f150b1eb7765a805bec0ff618cb718b3
|
||||||
specs:
|
specs:
|
||||||
rubocop-discourse (2.5.0)
|
rubocop-discourse (2.5.0)
|
||||||
rubocop (>= 1.1.0)
|
rubocop (>= 1.1.0)
|
||||||
@ -428,7 +428,7 @@ GEM
|
|||||||
rubocop-ast (>= 1.19.1, < 2.0)
|
rubocop-ast (>= 1.19.1, < 2.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 1.4.0, < 3.0)
|
unicode-display_width (>= 1.4.0, < 3.0)
|
||||||
rubocop-ast (1.20.1)
|
rubocop-ast (1.21.0)
|
||||||
parser (>= 3.1.1.0)
|
parser (>= 3.1.1.0)
|
||||||
rubocop-rspec (2.12.1)
|
rubocop-rspec (2.12.1)
|
||||||
rubocop (~> 1.31)
|
rubocop (~> 1.31)
|
||||||
|
@ -245,4 +245,56 @@ RSpec.describe DiscourseRedis do
|
|||||||
expect(redis_proxy.calls).to eq([:evalsha, :eval, :evalsha, :evalsha])
|
expect(redis_proxy.calls).to eq([:evalsha, :eval, :evalsha, :evalsha])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".new_redis_store" do
|
||||||
|
let(:cache) { Cache.new(namespace: 'foo') }
|
||||||
|
let(:store) { DiscourseRedis.new_redis_store }
|
||||||
|
|
||||||
|
before do
|
||||||
|
cache.redis.del("key")
|
||||||
|
store.delete("key")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can store stuff" do
|
||||||
|
store.fetch("key") do
|
||||||
|
"key in store"
|
||||||
|
end
|
||||||
|
|
||||||
|
r = store.read("key")
|
||||||
|
|
||||||
|
expect(r).to eq("key in store")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't collide with our Cache" do
|
||||||
|
store.fetch("key") do
|
||||||
|
"key in store"
|
||||||
|
end
|
||||||
|
|
||||||
|
cache.fetch("key") do
|
||||||
|
"key in cache"
|
||||||
|
end
|
||||||
|
|
||||||
|
r = store.read("key")
|
||||||
|
|
||||||
|
expect(r).to eq("key in store")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can be cleared without clearing our cache" do
|
||||||
|
cache.clear
|
||||||
|
store.clear
|
||||||
|
|
||||||
|
store.fetch("key") do
|
||||||
|
"key in store"
|
||||||
|
end
|
||||||
|
|
||||||
|
cache.fetch("key") do
|
||||||
|
"key in cache"
|
||||||
|
end
|
||||||
|
|
||||||
|
store.clear
|
||||||
|
|
||||||
|
expect(store.read("key")).to eq(nil)
|
||||||
|
expect(cache.fetch("key")).to eq("key in cache")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.describe "DistributedCache extensions" do
|
RSpec.describe DistributedCache do
|
||||||
let(:cache) { DistributedCache.new('mytest') }
|
let(:cache) { described_class.new('mytest') }
|
||||||
|
|
||||||
it "can defer_get_set" do
|
it "can defer_get_set" do
|
||||||
messages = MessageBus.track_publish("/distributed_hash") do
|
messages = MessageBus.track_publish("/distributed_hash") do
|
||||||
|
@ -86,9 +86,8 @@ RSpec.describe Onebox::Engine do
|
|||||||
expect(result).to match(/https/)
|
expect(result).to match(/https/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
RSpec.describe ".onebox_name" do
|
describe ".onebox_name" do
|
||||||
module ScopeForTemplateName
|
module ScopeForTemplateName
|
||||||
class TemplateNameOnebox
|
class TemplateNameOnebox
|
||||||
include Onebox::Engine
|
include Onebox::Engine
|
||||||
@ -104,4 +103,5 @@ RSpec.describe ".onebox_name" do
|
|||||||
it "should not include the word Onebox" do
|
it "should not include the word Onebox" do
|
||||||
expect(onebox_name).not_to include("onebox", "Onebox")
|
expect(onebox_name).not_to include("onebox", "Onebox")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'cache'
|
|
||||||
|
|
||||||
RSpec.describe "Redis Store" do
|
|
||||||
|
|
||||||
let :cache do
|
|
||||||
Cache.new(namespace: 'foo')
|
|
||||||
end
|
|
||||||
|
|
||||||
let :store do
|
|
||||||
DiscourseRedis.new_redis_store
|
|
||||||
end
|
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
cache.redis.del "key"
|
|
||||||
store.delete "key"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "can store stuff" do
|
|
||||||
store.fetch "key" do
|
|
||||||
"key in store"
|
|
||||||
end
|
|
||||||
|
|
||||||
r = store.read "key"
|
|
||||||
|
|
||||||
expect(r).to eq("key in store")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't collide with our Cache" do
|
|
||||||
|
|
||||||
store.fetch "key" do
|
|
||||||
"key in store"
|
|
||||||
end
|
|
||||||
|
|
||||||
cache.fetch "key" do
|
|
||||||
"key in cache"
|
|
||||||
end
|
|
||||||
|
|
||||||
r = store.read "key"
|
|
||||||
|
|
||||||
expect(r).to eq("key in store")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "can be cleared without clearing our cache" do
|
|
||||||
cache.clear
|
|
||||||
store.clear
|
|
||||||
|
|
||||||
store.fetch "key" do
|
|
||||||
"key in store"
|
|
||||||
end
|
|
||||||
|
|
||||||
cache.fetch "key" do
|
|
||||||
"key in cache"
|
|
||||||
end
|
|
||||||
|
|
||||||
store.clear
|
|
||||||
|
|
||||||
expect(store.read("key")).to eq(nil)
|
|
||||||
expect(cache.fetch("key")).to eq("key in cache")
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
@ -10,7 +10,7 @@ module QualityTitleValidatorSpec
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe "A record validated with QualityTitleValidator" do
|
RSpec.describe QualityTitleValidator do
|
||||||
let(:valid_title) { "hello this is my cool topic! welcome: all;" }
|
let(:valid_title) { "hello this is my cool topic! welcome: all;" }
|
||||||
let(:short_title) { valid_title.slice(0, SiteSetting.min_topic_title_length - 1) }
|
let(:short_title) { valid_title.slice(0, SiteSetting.min_topic_title_length - 1) }
|
||||||
let(:long_title) { valid_title.center(SiteSetting.max_topic_title_length + 1, 'x') }
|
let(:long_title) { valid_title.center(SiteSetting.max_topic_title_length + 1, 'x') }
|
||||||
|
Reference in New Issue
Block a user