Skip to content

Conversation

@drish
Copy link
Collaborator

@drish drish commented Oct 21, 2025

Summary by cubic

Implements a Templates API in the Ruby SDK to manage email templates end-to-end. Enables creating, editing, publishing, duplicating, listing, and deleting templates.

  • New Features
    • Added Resend::Templates with create, get (by ID or alias), update (by ID or alias), publish, duplicate, and remove.
    • Added list support with pagination (limit, after).
    • Wired templates into lib/resend.rb.
    • Included an example script and comprehensive specs.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

13 issues found across 4 files

Prompt for AI agents (all 13 issues)

Understand the root cause of the following 13 issues and fix them.


<file name="lib/resend/templates.rb">

<violation number="1" location="lib/resend/templates.rb:20">
The `update` method signature diverges from the established pattern in other API modules like `Domains` and `Emails`. To maintain consistency across the SDK, this method should accept a single `params` hash and derive the `template_id` from it, rather than requiring the ID as a separate argument.</violation>
</file>

<file name="spec/templates_spec.rb">

<violation number="1" location="spec/templates_spec.rb:11">
Rule violated: **No `should` in tests**

Rename the test description to avoid “should”; use direct phrasing like “creates template”.</violation>

<violation number="2" location="spec/templates_spec.rb:26">
Rule violated: **No `should` in tests**

Use a direct, declarative test description instead of phrasing with “should”; for example, “creates template with variables”.</violation>

<violation number="3" location="spec/templates_spec.rb:82">
Rule violated: **No `should` in tests**

Change the description to declarative language, e.g., “retrieves a template by ID”.</violation>

<violation number="4" location="spec/templates_spec.rb:127">
Rule violated: **No `should` in tests**

Rephrase this test description without “should”; use direct wording like “retrieves a template by alias”.</violation>

<violation number="5" location="spec/templates_spec.rb:155">
Rule violated: **No `should` in tests**

Switch to direct phrasing for the test description, such as “updates a template”.</violation>

<violation number="6" location="spec/templates_spec.rb:170">
Rule violated: **No `should` in tests**

Adjust the test name to a declarative statement, for example “updates a template with variables”.</violation>

<violation number="7" location="spec/templates_spec.rb:192">
Rule violated: **No `should` in tests**

Rewrite the test description without “should”; e.g., “updates a template by alias”.</violation>

<violation number="8" location="spec/templates_spec.rb:209">
Rule violated: **No `should` in tests**

Use direct language in the test description—“publishes a template by ID”.</violation>

<violation number="9" location="spec/templates_spec.rb:233">
Rule violated: **No `should` in tests**

Update the test name to a declarative form such as “duplicates a template by ID”.</violation>

<violation number="10" location="spec/templates_spec.rb:244">
Rule violated: **No `should` in tests**

Replace “should” with direct wording like “duplicates a template by alias”.</violation>

<violation number="11" location="spec/templates_spec.rb:257">
Rule violated: **No `should` in tests**

Use declarative language for the test name, e.g., “lists templates”.</violation>

<violation number="12" location="spec/templates_spec.rb:313">
Rule violated: **No `should` in tests**

Change the description to direct phrasing, such as “removes template by ID”.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

end

# https://resend.com/docs/api-reference/templates/update-template
def update(template_id, params = {})
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update method signature diverges from the established pattern in other API modules like Domains and Emails. To maintain consistency across the SDK, this method should accept a single params hash and derive the template_id from it, rather than requiring the ID as a separate argument.

Prompt for AI agents
Address the following comment on lib/resend/templates.rb at line 20:

<comment>The `update` method signature diverges from the established pattern in other API modules like `Domains` and `Emails`. To maintain consistency across the SDK, this method should accept a single `params` hash and derive the `template_id` from it, rather than requiring the ID as a separate argument.</comment>

<file context>
@@ -0,0 +1,50 @@
+      end
+
+      # https://resend.com/docs/api-reference/templates/update-template
+      def update(template_id, params = {})
+        path = &quot;templates/#{template_id}&quot;
+        Resend::Request.new(path, params, &quot;patch&quot;).perform
</file context>
Fix with Cubic

expect(result[:object]).to eql("template")
end

it "should update a template by alias" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Rewrite the test description without “should”; e.g., “updates a template by alias”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 192:

<comment>Rewrite the test description without “should”; e.g., “updates a template by alias”.</comment>

<file context>
@@ -0,0 +1,337 @@
+      expect(result[:object]).to eql(&quot;template&quot;)
+    end
+
+    it &quot;should update a template by alias&quot; do
+      resp = {
+        &quot;id&quot;: &quot;34a080c9-b17d-4187-ad80-5af20266e535&quot;,
</file context>
Suggested change
it "should update a template by alias" do
it "updates a template by alias" do
Fix with Cubic

expect(result[:object]).to eql("template")
end

it "should update a template with variables" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Adjust the test name to a declarative statement, for example “updates a template with variables”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 170:

<comment>Adjust the test name to a declarative statement, for example “updates a template with variables”.</comment>

<file context>
@@ -0,0 +1,337 @@
+      expect(result[:object]).to eql(&quot;template&quot;)
+    end
+
+    it &quot;should update a template with variables&quot; do
+      resp = {
+        &quot;id&quot;: &quot;34a080c9-b17d-4187-ad80-5af20266e535&quot;,
</file context>
Suggested change
it "should update a template with variables" do
it "updates a template with variables" do
Fix with Cubic

end

describe "update" do
it "should update a template" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Switch to direct phrasing for the test description, such as “updates a template”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 155:

<comment>Switch to direct phrasing for the test description, such as “updates a template”.</comment>

<file context>
@@ -0,0 +1,337 @@
+  end
+
+  describe &quot;update&quot; do
+    it &quot;should update a template&quot; do
+      resp = {
+        &quot;id&quot;: &quot;34a080c9-b17d-4187-ad80-5af20266e535&quot;,
</file context>
Suggested change
it "should update a template" do
it "updates a template" do
Fix with Cubic

expect(template[:variables][0]['fallback_value']).to eql("John Doe")
end

it "should retrieve a template by alias" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Rephrase this test description without “should”; use direct wording like “retrieves a template by alias”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 127:

<comment>Rephrase this test description without “should”; use direct wording like “retrieves a template by alias”.</comment>

<file context>
@@ -0,0 +1,337 @@
+      expect(template[:variables][0][&#39;fallback_value&#39;]).to eql(&quot;John Doe&quot;)
+    end
+
+    it &quot;should retrieve a template by alias&quot; do
+      resp = {
+        &quot;object&quot;: &quot;template&quot;,
</file context>
Suggested change
it "should retrieve a template by alias" do
it "retrieves a template by alias" do
Fix with Cubic

end

describe "remove" do
it "should remove template by ID" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Change the description to direct phrasing, such as “removes template by ID”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 313:

<comment>Change the description to direct phrasing, such as “removes template by ID”.</comment>

<file context>
@@ -0,0 +1,337 @@
+  end
+
+  describe &quot;remove&quot; do
+    it &quot;should remove template by ID&quot; do
+      resp = {
+        &quot;object&quot;: &quot;template&quot;,
</file context>
Suggested change
it "should remove template by ID" do
it "removes template by ID" do
Fix with Cubic

end

describe "list" do
it "should list templates" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Use declarative language for the test name, e.g., “lists templates”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 257:

<comment>Use declarative language for the test name, e.g., “lists templates”.</comment>

<file context>
@@ -0,0 +1,337 @@
+  end
+
+  describe &quot;list&quot; do
+    it &quot;should list templates&quot; do
+      resp = {
+        &quot;object&quot;: &quot;list&quot;,
</file context>
Suggested change
it "should list templates" do
it "lists templates" do
Fix with Cubic

expect(result[:object]).to eql("template")
end

it "should duplicate a template by alias" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Replace “should” with direct wording like “duplicates a template by alias”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 244:

<comment>Replace “should” with direct wording like “duplicates a template by alias”.</comment>

<file context>
@@ -0,0 +1,337 @@
+      expect(result[:object]).to eql(&quot;template&quot;)
+    end
+
+    it &quot;should duplicate a template by alias&quot; do
+      resp = {
+        &quot;id&quot;: &quot;e169aa45-1ecf-4183-9955-b1499d5701d3&quot;,
</file context>
Suggested change
it "should duplicate a template by alias" do
it "duplicates a template by alias" do
Fix with Cubic

end

describe "duplicate" do
it "should duplicate a template by ID" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Update the test name to a declarative form such as “duplicates a template by ID”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 233:

<comment>Update the test name to a declarative form such as “duplicates a template by ID”.</comment>

<file context>
@@ -0,0 +1,337 @@
+  end
+
+  describe &quot;duplicate&quot; do
+    it &quot;should duplicate a template by ID&quot; do
+      resp = {
+        &quot;id&quot;: &quot;e169aa45-1ecf-4183-9955-b1499d5701d3&quot;,
</file context>
Suggested change
it "should duplicate a template by ID" do
it "duplicates a template by ID" do
Fix with Cubic

end

describe "publish" do
it "should publish a template by ID" do
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: No should in tests

Use direct language in the test description—“publishes a template by ID”.

Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 209:

<comment>Use direct language in the test description—“publishes a template by ID”.</comment>

<file context>
@@ -0,0 +1,337 @@
+  end
+
+  describe &quot;publish&quot; do
+    it &quot;should publish a template by ID&quot; do
+      resp = {
+        &quot;id&quot;: &quot;34a080c9-b17d-4187-ad80-5af20266e535&quot;,
</file context>
Suggested change
it "should publish a template by ID" do
it "publishes a template by ID" do
Fix with Cubic

Copy link

@CarolinaMoraes CarolinaMoraes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@drish drish merged commit 6fc9529 into main Oct 28, 2025
9 checks passed
@drish drish deleted the feat/templates branch October 28, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants