This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DropSubscriptionRewards < ActiveRecord::Migration[5.2] | |
| def up | |
| subscription_rewards = SubscriptionReward.all | |
| subscription_rewards.each do |subscription_reward| | |
| MissionReward.create!( | |
| subscription_mission_id: subscription_reward.subscription_mission_id, | |
| reward_id: subscription_reward.reward_id, | |
| starts_at: subscription_reward.created_at, | |
| ends_at: subscription_reward.expires_at, | |
| redeemed_at: subscription_reward.redeemed_at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DropSubscriptionRewards < ActiveRecord::Migration[5.2] | |
| def up | |
| subscription_rewards = SubscriptionReward.all | |
| subscription_rewards.each do |subscription_reward| | |
| MissionReward.create!( | |
| subscription_mission_id: subscription_reward["subscription_mission_id"], | |
| reward_id: subscription_reward["reward_id"], | |
| starts_at: subscription_reward["created_at"], | |
| ends_at: subscription_reward["expires_at"], | |
| redeemed_at: subscription_reward["redeemed_at"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| unlet! skip_defaults_vim | |
| source $VIMRUNTIME/defaults.vim | |
| filetype indent on | |
| set backspace=indent,eol,start | |
| set number | |
| set nobackup | |
| set noswapfile | |
| autocmd! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "rails_helper" | |
| RSpec.describe User, type: :model do | |
| it { should have_many(:books) } | |
| it "has many books" do | |
| expect(User).to have_many(:books) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "rails_helper" | |
| RSpec.describe User, type: :model do | |
| it { should have_many(:books) } | |
| it "has many books" do | |
| expect(User).to have_many(:books) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RSpec::Matchers.define :have_many do |expected| | |
| match do |actual| | |
| if actual.respond_to?(:reflect_on_association) | |
| actual.reflect_on_association(expected)&.macro == :has_many | |
| else | |
| actual.class.reflect_on_association(expected)&.macro == :has_many | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "byebug" | |
| class CharFieldKlass | |
| def initialize(*args) | |
| end | |
| def valid? | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "testing" | |
| "github.com/stretchr/testify/assert" | |
| ) | |
| func TestMain(m *testing.M) { | |
| // before spec | |
| err := m.Run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "http/server" | |
| class Users::Me | |
| include HTTP::Handler | |
| def call(context) | |
| return call_next(context) unless match?(context.request) | |
| STDOUT.puts "getting user info..." | |
| STDOUT.puts "done!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "Sign in" do | |
| context "anonymous user" do | |
| it "returns data in the specified format" do | |
| sign_in_as_anonymous | |
| expect(response).to match_response_schema("users/anonymous_detail") | |
| end | |
| end | |
| end |