Commit 285926918b95f1d771bf4e9c84972d4e55b41ea9
1 parent
7ec5ff4d
Exists in
spb-stable
and in
2 other branches
Serialize last_fetched_at as a string with seconds
Showing
4 changed files
with
4 additions
and
4 deletions
Show diff stats
app/controllers/projects/notes_controller.rb
| @@ -5,7 +5,7 @@ class Projects::NotesController < Projects::ApplicationController | @@ -5,7 +5,7 @@ class Projects::NotesController < Projects::ApplicationController | ||
| 5 | before_filter :authorize_admin_note!, only: [:update, :destroy] | 5 | before_filter :authorize_admin_note!, only: [:update, :destroy] |
| 6 | 6 | ||
| 7 | def index | 7 | def index |
| 8 | - current_fetched_at = Time.now | 8 | + current_fetched_at = Time.now.to_i |
| 9 | @notes = NotesFinder.new.execute(project, current_user, params) | 9 | @notes = NotesFinder.new.execute(project, current_user, params) |
| 10 | 10 | ||
| 11 | notes_json = { notes: [], last_fetched_at: current_fetched_at } | 11 | notes_json = { notes: [], last_fetched_at: current_fetched_at } |
app/finders/notes_finder.rb
| @@ -4,7 +4,7 @@ class NotesFinder | @@ -4,7 +4,7 @@ class NotesFinder | ||
| 4 | def execute(project, current_user, params) | 4 | def execute(project, current_user, params) |
| 5 | target_type = params[:target_type] | 5 | target_type = params[:target_type] |
| 6 | target_id = params[:target_id] | 6 | target_id = params[:target_id] |
| 7 | - last_fetched_at = params.fetch(:last_fetched_at) | 7 | + last_fetched_at = Time.at(params.fetch(:last_fetched_at).to_i) |
| 8 | 8 | ||
| 9 | notes = case target_type | 9 | notes = case target_type |
| 10 | when "commit" | 10 | when "commit" |
app/views/projects/notes/_notes_with_form.html.haml
| @@ -7,4 +7,4 @@ | @@ -7,4 +7,4 @@ | ||
| 7 | = render "projects/notes/form" | 7 | = render "projects/notes/form" |
| 8 | 8 | ||
| 9 | :javascript | 9 | :javascript |
| 10 | - new Notes("#{project_notes_path(target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, Time.now) | 10 | + new Notes("#{project_notes_path(target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}) |
spec/finders/notes_finder_spec.rb
| @@ -12,7 +12,7 @@ describe NotesFinder do | @@ -12,7 +12,7 @@ describe NotesFinder do | ||
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | describe :execute do | 14 | describe :execute do |
| 15 | - let(:params) { { target_id: commit.id, target_type: 'commit', last_fetched_at: 1.hour.ago } } | 15 | + let(:params) { { target_id: commit.id, target_type: 'commit', last_fetched_at: 1.hour.ago.to_i } } |
| 16 | 16 | ||
| 17 | before do | 17 | before do |
| 18 | note1 | 18 | note1 |