Louis Knapp
9 years ago
8 changed files with 49 additions and 9 deletions
@ -1,5 +1,7 @@ |
|||||
# Date |
# Date |
||||
Date::DATE_FORMATS[:default] = "%m/%d/%Y" |
Date::DATE_FORMATS[:default] = "%m/%d/%Y" |
||||
|
Date::DATE_FORMATS[:db] = "%m/%d/%Y" |
||||
|
|
||||
# Time |
# Time |
||||
Time::DATE_FORMATS[:default] = "%m/%d/%Y" |
Time::DATE_FORMATS[:default] = "%m/%d/%Y" |
||||
|
Date::DATE_FORMATS[:db] = "%m/%d/%Y" |
||||
|
@ -0,0 +1,17 @@ |
|||||
|
class ChangeClientApplicationDateToString < ActiveRecord::Migration |
||||
|
def up |
||||
|
add_column :clients, :application_datetime, :datetime |
||||
|
Client.all.to_a.each{ |client| |
||||
|
if client.application_date |
||||
|
client.update_attribute(:application_datetime, client.application_date) |
||||
|
end |
||||
|
} |
||||
|
rename_column :clients, :application_date, :application_date_bkp |
||||
|
rename_column :clients, :application_datetime, :application_date |
||||
|
end |
||||
|
|
||||
|
def down |
||||
|
remove_column :clients, :application_date |
||||
|
rename_column :clients, :application_date_bkp, :application_date |
||||
|
end |
||||
|
end |
@ -0,0 +1,17 @@ |
|||||
|
require 'spec_helper' |
||||
|
|
||||
|
describe ClientsController do |
||||
|
let(:user){FactoryGirl.create(:user)} |
||||
|
let(:client){FactoryGirl.create(:client)} |
||||
|
|
||||
|
before :each do |
||||
|
sign_in user |
||||
|
end |
||||
|
|
||||
|
describe "PUT #update" do |
||||
|
it "updates a client with an application date" do |
||||
|
put :update, id: client.id, client: {application_date: "12/21/2015"} |
||||
|
expect(client.reload.application_date.strftime('%m/%d/%Y')).to eq("12/21/2015") |
||||
|
end |
||||
|
end |
||||
|
end |
Loading…
Reference in new issue