mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 23:38:29 +08:00
Adding post details in preparation for the API importer code.
This commit is contained in:
@ -26,6 +26,8 @@ describe Post do
|
||||
it { should have_many :post_uploads }
|
||||
it { should have_many :uploads }
|
||||
|
||||
it { should have_many :post_details }
|
||||
|
||||
it { should rate_limit }
|
||||
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
@ -760,4 +762,20 @@ describe Post do
|
||||
end
|
||||
end
|
||||
|
||||
describe "details" do
|
||||
it "adds details" do
|
||||
post = Fabricate.build(:post)
|
||||
post.add_detail("key", "value")
|
||||
post.post_details.size.should == 1
|
||||
post.post_details.first.key.should == "key"
|
||||
post.post_details.first.value.should == "value"
|
||||
end
|
||||
|
||||
it "can find a post by a detail" do
|
||||
detail = Fabricate(:post_detail)
|
||||
post = detail.post
|
||||
Post.find_by_detail(detail.key, detail.value).id.should == post.id
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user