Skip to content

Commit

Permalink
Fix client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angusmcleod committed Aug 16, 2024
1 parent eb3b5ef commit bda52bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 6 additions & 0 deletions db/migrate/20240816031155_add_default_to_connection_client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true
class AddDefaultToConnectionClient < ActiveRecord::Migration[7.1]
def change
change_column_default :discourse_events_connections, :client, 'events'
end
end
15 changes: 5 additions & 10 deletions spec/requests/discourse_events/connection_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
},
category_id: category.id,
source_id: source.id,
client: "events",
},
}

Expand All @@ -59,7 +58,6 @@
},
category_id: -1,
source_id: source.id,
client: "events",
},
}

Expand All @@ -68,31 +66,29 @@
end

it "updates connections" do
new_client = "discourse_events"
new_cat = Fabricate(:category)

put "/admin/plugins/events/connection/#{connection.id}.json",
params: {
connection: {
client: new_client,
category_id: new_cat.id,
},
}

expect(response.status).to eq(200)
expect(response.parsed_body["connection"]["client"]).to eq(new_client)
expect(response.parsed_body["connection"]["category_id"]).to eq(new_cat.id)
end

it "handles invalid update params" do
put "/admin/plugins/events/connection/#{connection.id}.json",
params: {
connection: {
client: "invalid_client",
category_id: -1,
},
}

expect(response.status).to eq(400)
expect(response.parsed_body["errors"].first).to eq(
"Client invalid_client is not a valid connection client",
)
expect(response.parsed_body["errors"].first).to eq("Category can't be blank")
end

it "destroys connections" do
Expand All @@ -117,7 +113,6 @@
put "/admin/plugins/events/connection/#{connection.id}.json",
params: {
connection: {
client: "discourse_events",
filters: [
{
id: "new",
Expand Down

0 comments on commit bda52bc

Please sign in to comment.