Skip to content

Commit

Permalink
CV2-4869: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Jul 22, 2024
1 parent 1342e6f commit 5f19724
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_04_20_104318) do
ActiveRecord::Schema.define(version: 2024_07_19_183518) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -233,7 +233,7 @@
end

create_table "clusters", force: :cascade do |t|
t.integer "project_media_id"
t.integer "project_media_id", null: false
t.datetime "first_item_at"
t.datetime "last_item_at"
t.datetime "created_at", null: false
Expand Down
1 change: 1 addition & 0 deletions lib/sample_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ def create_tipline_request(options = {})
end

def create_cluster(options = {})
options[:project_media] = create_project_media if options[:project_media].blank?
team = options[:project_media]&.team || create_team
options[:feed] = options[:feed] || create_feed({ team: team })
c = Cluster.new
Expand Down
4 changes: 3 additions & 1 deletion test/models/cluster_project_media_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ def setup
end

test "should create cluster project media" do
c = create_cluster
pm = create_project_media
assert_difference 'ClusterProjectMedia.count' do
create_cluster_project_media
create_cluster_project_media cluster: c, project_media: pm
end
end

Expand Down
9 changes: 5 additions & 4 deletions test/models/cluster_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ def setup
end

test "should have items" do
c = create_cluster
pm = create_project_media
c = create_cluster project_media: pm
pm1 = create_project_media cluster: c
pm2 = create_project_media cluster: c
assert_equal [pm1, pm2].sort, c.reload.items.sort
assert_equal [pm, pm1, pm2].sort, c.reload.items.sort
end

test "should access cluster" do
Expand Down Expand Up @@ -69,8 +70,8 @@ def setup

test "should return size" do
c = create_cluster
assert_equal 0, c.size
c.project_medias << create_project_media
assert_equal 1, c.size
c.project_medias << create_project_media
assert_equal 2, c.size
end
end

0 comments on commit 5f19724

Please sign in to comment.