Skip to content

Commit

Permalink
Fix timestamp editing
Browse files Browse the repository at this point in the history
  • Loading branch information
yamax2 committed Sep 14, 2022
1 parent bcd8d91 commit 2ce2e9e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ GEM
rexml (3.2.5)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rspec-expectations (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
Expand All @@ -332,7 +332,7 @@ GEM
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rspec-support (3.11.1)
rubocop (1.36.0)
json (~> 2.3)
parallel (~> 1.10)
Expand All @@ -352,8 +352,8 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rspec (2.12.1)
rubocop (~> 1.31)
rubocop-rspec (2.13.1)
rubocop (~> 1.33)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
sass-rails (6.0.0)
Expand All @@ -379,10 +379,10 @@ GEM
sidekiq (>= 4.2.1)
sidekiq-failures (1.0.4)
sidekiq (>= 4.0.0)
sidekiq-throttled (0.16.2)
sidekiq-throttled (0.17.0)
concurrent-ruby
redis-prescription
sidekiq
sidekiq (>= 6.4)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -424,7 +424,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.2.0)
unicode-display_width (2.3.0)
vcr (6.1.0)
webmock (3.18.1)
addressable (>= 2.8.0)
Expand Down
3 changes: 2 additions & 1 deletion app/views/admin/photos/edit.slim
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
.input-group
= f.text_field :original_timestamp, class: 'form-control datetimepicker',
autocomplete: 'off',
data: {toggle: 'datetimepicker', target: '#photo_original_timestamp'}
data: {toggle: 'datetimepicker', target: '#photo_original_timestamp'},
value: @photo.original_timestamp&.to_fs
.input-group-append
button.btn.btn-outline-secondary.btn-clear type="button"
= t('.clear')
Expand Down
7 changes: 5 additions & 2 deletions spec/controllers/admin/photos_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,16 @@
context 'when successful update' do
let(:token) { create :'yandex/token' }
let!(:photo) { create :photo, storage_filename: 'test', yandex_token: token, name: 'my' }
let(:timestamp) { Time.zone.local(2022, 9, 15, 21, 0, 28) }

before { put admin_photo_url(id: photo.id, photo: {name: 'test', rotated: 1}) }
before do
put admin_photo_url(id: photo.id, photo: {name: 'test', rotated: 1, original_timestamp: timestamp.to_fs})
end

it do
expect(assigns(:photo)).to eq(photo)
expect(assigns(:photo)).to be_valid
expect(assigns(:photo)).to have_attributes(name: 'test', rotated: 1)
expect(assigns(:photo)).to have_attributes(name: 'test', rotated: 1, original_timestamp: timestamp)

expect(response).to redirect_to(edit_admin_photo_path(photo))
end
Expand Down

0 comments on commit 2ce2e9e

Please sign in to comment.