Skip to content

Commit

Permalink
feat: create mocked quest endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
luizmuraro committed Oct 1, 2024
1 parent 4fdaa65 commit 48ce26b
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/govquests-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "bin/dev"
"dev": "cd rails_app && bin/dev"
},
"keywords": [],
"author": "",
Expand Down
69 changes: 69 additions & 0 deletions apps/govquests-api/rails_app/app/controllers/quests_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# app/controllers/quests_controller.rb
class QuestsController < ApplicationController
def index
quests = [
{
img_url: "https://file.coinexstatic.com/2023-11-16/BB3FDB00283C55B4C36B94CFAC0C3271.png",
title: "Governance 101",
reward_type: "OP",
intro: "First things first: understand what are the Optimism Values and what is expect
of you in this important role.",
steps: [
{
content: "Code of Conduct",
duration: 15,
status: "start"
},
{
content: "Optimistic Vision",
duration: 10,
status: "start"

},
{
content: "Working Constitution",
duration: 15,
status: "start"
},
{
content: "Delegate Expectations",
duration: 12,
status: "start"
},
]
},
{
img_url: "https://file.coinexstatic.com/2023-11-16/BB3FDB00283C55B4C36B94CFAC0C3271.png",
title: "Governance 101",
reward_type: "POINTS",
intro: "First things first: understand what are the Optimism Values and what is expect
of you in this important role.",
steps: [
{
content: "Code of Conduct",
duration: 15,
status: "start"
},
{
content: "Optimistic Vision",
duration: 15,
status: "start"

},
{
content: "Working Constitution",
duration: 20,
status: "start"
},
{
content: "Delegate Expectations",
duration: 25,
status: "start"
},
]
},
]

render json: quests
end
end
8 changes: 8 additions & 0 deletions apps/govquests-api/rails_app/app/models/quest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Quest < ApplicationRecord
validates :img_url, presence: true
validates :title, presence: true
validates :reward_type, presence: true
validates :intro, presence: true

serialize :steps, Array
end
1 change: 1 addition & 0 deletions apps/govquests-api/rails_app/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

# Defines the root path route ("/")
# root "posts#index"
get 'quests', to: 'quests#index'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CreateQuests < ActiveRecord::Migration[8.0]
def change
create_table :quests do |t|
t.string :img_url
t.string :title
t.string :reward_type
t.text :intro
t.text :steps

t.timestamps
end
end
end
12 changes: 11 additions & 1 deletion apps/govquests-api/rails_app/db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class QuestControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
15 changes: 15 additions & 0 deletions apps/govquests-api/rails_app/test/fixtures/quests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
img_url: MyString
title: MyString
reward_type: MyString
intro: MyText
steps: MyText

two:
img_url: MyString
title: MyString
reward_type: MyString
intro: MyText
steps: MyText
7 changes: 7 additions & 0 deletions apps/govquests-api/rails_app/test/models/quest_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class QuestTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit 48ce26b

Please sign in to comment.