Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix: detect attempting to create a post with published_at in miliseconds

  • Loading branch information...
commit 476ac9b06f19f5aa8f5fb0cd66edea4fabd2915d 1 parent 41ca9e0
@jvatic jvatic authored
Showing with 13 additions and 0 deletions.
  1. +1 −0  lib/tentd/model/post.rb
  2. +12 −0 spec/integration/model/post_spec.rb
View
1  lib/tentd/model/post.rb
@@ -69,6 +69,7 @@ def update(data)
end
def self.create(data)
+ data[:published_at] = Time.at(data[:published_at].to_time.to_i / 1000) if data[:published_at] && ((data[:published_at].to_time.to_i - Time.now.to_i) > 1000000000)
mentions = data.delete(:mentions)
post = super(data)
View
12 spec/integration/model/post_spec.rb
@@ -20,6 +20,18 @@ def push(item)
let(:other_follower) { Fabricate(:follower, :entity => 'https://marks.example.com') }
let(:entity_url) { 'https://alexdoe.example.org' }
+
+ it "should divide published_at by 1000 if it's in miliseconds" do
+ post_attributes = {
+ :published_at => Time.at(1349471384657),
+ :type => 'https://tent.io/types/post/status/v0.1.0',
+ :content => {}
+ }
+ post = described_class.create(post_attributes)
+ expect(post.published_at.to_time.to_i).to eq(1349471384)
+ end
+
+
it 'should send notification to all mentioned entities not already subscribed' do
post_type = 'https://tent.io/types/post/status/v0.1.0'
post_attrs = Fabricate.build(:post).attributes.merge(
Please sign in to comment.
Something went wrong with that request. Please try again.