mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 06:05:39 +08:00
Merge pull request #69 from gammons/master
use shared_examples_for versioning for posts, topics
This commit is contained in:
commit
36c3467f72
@ -21,6 +21,7 @@ describe Post do
|
|||||||
{user: topic.user, topic: topic}
|
{user: topic.user, topic: topic}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like "a versioned model"
|
||||||
|
|
||||||
describe 'post uniqueness' do
|
describe 'post uniqueness' do
|
||||||
|
|
||||||
@ -264,10 +265,6 @@ describe Post do
|
|||||||
let(:post) { Fabricate(:post, post_args) }
|
let(:post) { Fabricate(:post, post_args) }
|
||||||
let(:first_version_at) { post.last_version_at }
|
let(:first_version_at) { post.last_version_at }
|
||||||
|
|
||||||
it 'has an initial version of 1' do
|
|
||||||
post.cached_version.should == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has one version in all_versions' do
|
it 'has one version in all_versions' do
|
||||||
post.all_versions.size.should == 1
|
post.all_versions.size.should == 1
|
||||||
end
|
end
|
||||||
|
@ -23,6 +23,8 @@ describe Topic do
|
|||||||
|
|
||||||
it { should rate_limit }
|
it { should rate_limit }
|
||||||
|
|
||||||
|
it_behaves_like "a versioned model"
|
||||||
|
|
||||||
context '.title_quality' do
|
context '.title_quality' do
|
||||||
|
|
||||||
it "strips a title when identifying length" do
|
it "strips a title when identifying length" do
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
shared_examples_for "a versioned model" do
|
||||||
|
let(:model) { Fabricate(described_class.to_s.downcase) }
|
||||||
|
let(:first_version_at) { model.last_version_at }
|
||||||
|
|
||||||
|
it 'should be versioned' do
|
||||||
|
model.should respond_to(:version)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has an initial version of 1' do
|
||||||
|
model.version.should == 1
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user