test/test_helper.rb in groupdate-2.2.0 vs test/test_helper.rb in groupdate-2.2.1

- old
+ new

@@ -16,21 +16,30 @@ # rails does this in activerecord/lib/active_record/railtie.rb ActiveRecord::Base.default_timezone = :utc ActiveRecord::Base.time_zone_aware_attributes = true class User < ActiveRecord::Base + has_many :posts end +class Post < ActiveRecord::Base +end + # migrations %w(postgresql mysql2).each do |adapter| ActiveRecord::Base.establish_connection :adapter => adapter, :database => "groupdate_test", :username => adapter == "mysql2" ? "root" : nil ActiveRecord::Migration.create_table :users, :force => true do |t| t.string :name t.integer :score t.timestamp :created_at end + + ActiveRecord::Migration.create_table :posts, :force => true do |t| + t.references :user + t.timestamp :created_at + end end module TestGroupdate def setup @@ -602,9 +611,16 @@ def test_format_multiple_groups create_user "2014-03-01 00:00:00 UTC" assert_equal ({["Sun", 1] => 1}), User.group_by_week(:created_at, format: "%a").group(:score).count assert_equal ({[1, "Sun"] => 1}), User.group(:score).group_by_week(:created_at, format: "%a").count + end + + # associations + + def test_associations + user = create_user("2014-03-01 00:00:00 UTC") + assert_empty user.posts.group_by_day(:created_at).count end # helpers def assert_format(method, expected, format, options = {})