Skip to content

Added spec for datetime field#2426

Closed
billguy wants to merge 2 commits into
railsadminteam:masterfrom
billguy:datetime_field_bug
Closed

Added spec for datetime field#2426
billguy wants to merge 2 commits into
railsadminteam:masterfrom
billguy:datetime_field_bug

Conversation

@billguy

@billguy billguy commented Oct 8, 2015

Copy link
Copy Markdown

Rails 4.2.3
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
OSX 10.11

It seems after v0.6.8 that when a custom Rails config.time_zone is used and you save a datetime field without altering it, RailsAdmin appears to mutate the value of the field. I'm not certain why this is happening. It does appear to work correctly when config.time_zone is not set.

@billguy billguy changed the title Added spec for datetime field #2425 Added spec for datetime field Oct 8, 2015
@tagliala

Copy link
Copy Markdown
Contributor

I also noticed a wrong behaviour in datetime management, but I didn't take a deeper look

@dalpo

dalpo commented Oct 10, 2015

Copy link
Copy Markdown
Contributor

@tagliala @billguy What rails_admin version are you using, v0.7.0 or the HEAD from github?
Could be introduced by this PR #2391?

@tagliala

Copy link
Copy Markdown
Contributor

Add to your application.rb

config.time_zone = 'Rome'

Model:

# Schema
create_table "players", force: :cascade do |t|
  t.string   "name"
  t.integer  "team_id"
  t.datetime "birthday"
end

# Player.rb
class Player < ActiveRecord::Base
  validates :name, presence: true
end

# Rails admin config
config.model Player do
  field :name
  field :birthday
end

Using master branch: open an existing object, save, date will be increased by 2 hours each save

Using the gem version 0.7.0: everything is fine

Tried to bisect, here are the results:

fe2899fdeb48f4cdf33c0616f0024df13fd32f14 is the first bad commit
commit fe2899fdeb48f4cdf33c0616f0024df13fd32f14
Author: Andrea Dal Ponte
Date:   Sun Aug 30 19:59:13 2015 +0200

    Refactor date and datetime input fields logic

:040000 040000 ad2f41a159a56c28f86ac40fecb0c5b407061584 dda00cf24bd68c05d8685fa064a0c39f5c2f874c M  app
:040000 040000 10f4c500df39be9dd6280211f5ff1836140046fe 47d028d079923a986feba54ddb344ea56e5e3366 M  config
:040000 040000 47fa2498ec535d49dccd17c8f5556af339baf4de 9e980e8ae75c0ec82022b65df1c648ff3a12387c M  lib
:040000 040000 a83f9a4cc0d568325bcd5e0437798cce391a92b7 7b5eac30cb9e2a4fb90e986b1ae58cfc349ee679 M  spec

dalpo@fe2899f

@tagliala

Copy link
Copy Markdown
Contributor

@dalpo any news on this one? Unfortunately I can't take a deeper look by myself at the moment

@dalpo

dalpo commented Oct 14, 2015

Copy link
Copy Markdown
Contributor

I found the issue! I hope to fix it and make a PR this weekend.

@tagliala

Copy link
Copy Markdown
Contributor

Great news, thanks!

@dalpo dalpo mentioned this pull request Oct 31, 2015
dalpo pushed a commit to dalpo/rails_admin that referenced this pull request Nov 3, 2015
dalpo pushed a commit to dalpo/rails_admin that referenced this pull request Nov 11, 2015
dalpo pushed a commit to dalpo/rails_admin that referenced this pull request Nov 12, 2015
@dalpo

dalpo commented Nov 14, 2015

Copy link
Copy Markdown
Contributor

This PR can be closed by #2448

@tagliala

Copy link
Copy Markdown
Contributor

@dalpo thanks!

I can confirm that #2426 (comment) is not an issue anymore

@mshibuya mshibuya closed this Nov 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants