This file contains 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
offset = User.maximum(:id) | |
... | |
uid = comment.user_id + offset | |
Comment.new(commentable: postable, | |
text: comment.text, | |
user_id: uid).save(validate: false) |
This file contains 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
task :import do | |
OtherUser.find_each do |other_user| | |
user = User.create!(email: other_user.email, | |
name: other_user.name) | |
other_user.image_posts.each do |other| | |
image = Image.create!(file_path: other.file_path, | |
file_size: other.file_size, | |
height: other.height, | |
width: other.width) | |
Post.create!(postable: image, |
This file contains 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 OtherUser < ApplicationRecord | |
establish_connection :competitor | |
self.table_name = :users | |
has_many :video_posts, class_name: 'OtherVideoPost', foreign_key: 'user_id' | |
has_many :image_posts, class_name: 'OtherImagePost', foreign_key: 'user_id' | |
has_many :text_posts, class_name: 'OtherTextPost', foreign_key: 'user_id' | |
has_many :profile_comments, class_name: 'OtherProfileComment', foreign_key: 'user_id' | |
end |
This file contains 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
competitor: | |
adapter: mysql2 | |
database: competitor_prod | |
username: secret_user | |
password: secret_password |
This file contains 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 'acceptance_helper' | |
resource 'Posts' do | |
explanation 'Posts are entities holding some text information. | |
They can be created and seen by anyone' | |
post '/posts' do | |
with_options scope: :post do | |
parameter :title, 'Title of a post. Can be empty' | |
parameter :body, 'Main text of a post. Must be longer than 10 letters', required: true |
This file contains 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 'acceptance_helper' | |
resource 'Posts' do | |
explanation 'Posts are entities holding some text information. | |
They can be created and seen by anyone' | |
post '/posts' do | |
with_options scope: :post do | |
parameter :title, 'Title of a post. Can be empty' | |
parameter :body, 'Main text of a post. Must be longer than 10 letters', required: true |
This file contains 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 'acceptance_helper' | |
resource 'Posts' do | |
explanation 'Posts are entities holding some text information. | |
They can be created and seen by anyone' | |
post '/posts' do | |
# ... same as before ... | |
let(:title) { 'Foo' } |
This file contains 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 ApiRequest | |
attr_reader :status, | |
:response_keys, | |
:response_spec, | |
:specs, | |
:messages, | |
:stubs, | |
:params | |
def initialize |