Skip to content

Commit

Permalink
fix failing blueprint test for community resources as contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard M. Miller committed Jul 5, 2021
1 parent 271ea0f commit 6a55169
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/community_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.published

approved.where(publish_from: before_now, publish_until: nil).or(
approved.where(publish_from: before_now, publish_until: after_now)
)
)
end

def title; description; end
Expand Down
8 changes: 5 additions & 3 deletions spec/blueprints/contribution_blueprint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@
end

it 'can serialize a community resource as a contribution' do
expected_result = {"id" => nil, # not bothering to save the record in this test
resource = create(:community_resource)
expected_result = {
"id" => resource.id, # not bothering to save the record in this test
"category_tags" => [],
"contact_types" => [{"id" => 1, "name" => "Call"}],
"contribution_type" => "Community Resource",
"created_at" => 0,
"created_at" => resource.created_at.to_f * 1000,
"description" => "Food for the revolution",
"inexhaustible" => true,
"location" => nil,
Expand All @@ -91,7 +93,7 @@
"urgency" => {"id" => 4, "name" => "Anytime"},
"view_path" => nil
}
result = ContributionBlueprint.render(build(:community_resource), current_user: user)
result = ContributionBlueprint.render(resource, current_user: user)
expect(JSON.parse(result)).to eq(expected_result)
end
end

0 comments on commit 6a55169

Please sign in to comment.