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 Catalog < ApplicationRecord | |
| has_many :rewards | |
| has_many :campaigns | |
| 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
| {"data": | |
| {"id":1, | |
| "name":"Miss Rikki Parisian", | |
| "description":"Davis Runolfsdottir", | |
| "terms_and_conditions":null, | |
| "partner":null, | |
| "begins_at":"2020-02-05T00:00:00.000Z", | |
| "ends_at":"2020-02-13T00:00:00.000Z", | |
| "ordering":1, | |
| "images":[], |
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
| # reverse_number(12345) | |
| # => 54321 | |
| def reverse_number(number) | |
| raise 'Input must be number' unless number.is_a? Numeric | |
| reversed_numbers = [] | |
| # do the operation until all the numbers are modulused and divided | |
| loop do | |
| # modulus by 10 to get the remaining and add them to the reverse_numbers array | |
| reversed_numbers << number % 10 |
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.feature 'Dashboard', type: :feature, js: true do | |
| let!(:robot1) { FactoryBot.create(:robot, :qa_passed) } | |
| let!(:robot2) { FactoryBot.create(:robot, :factory_second) } | |
| let!(:robot3) { FactoryBot.create(:robot) } | |
| let!(:robot4) { FactoryBot.create(:robot, :with_shipment) } | |
| background { visit root_path } | |
| scenario 'send shipment' do |
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 Robot, 'Instance Methods', type: :model do | |
| context 'when rusty' do | |
| it 'should be recycled' do | |
| robot = FactoryBot.create(:robot, :rusty) | |
| expect(robot.should_be_recycled?).to eq true | |
| 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
| class Robot < ApplicationRecord | |
| validates :name, presence: true | |
| validates :color, presence: true | |
| belongs_to :color | |
| belongs_to :shipment, optional: true | |
| has_and_belongs_to_many :statuses | |
| def should_be_recycled? |
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 Robot, 'Validations', type: :model do | |
| it { is_expected.to validate_presence_of(:name) } | |
| it { is_expected.to validate_presence_of(:color) } | |
| end | |
| RSpec.describe Robot, 'Associations', type: :model do | |
| it { is_expected.to belong_to(:color) } | |
| it { is_expected.to have_and_belong_to_many(:statuses) } |
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 ServerConnection | |
| include Singleton | |
| def connection | |
| @connection ||= Server.new( | |
| key: ENV['ACCESS_KEY'], | |
| host: ENV['HOST'], | |
| username: ENV['USERNAME'] | |
| ) | |
| 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
| { | |
| "response": { | |
| "status": { | |
| "code": 200, | |
| "message": "OK" | |
| }, | |
| "body": { | |
| "type": "domain", | |
| "name": "some-domain.com", | |
| "price": "11.00", |
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 DTO::Domain | |
| attr_reader :type, :name, :price, :status | |
| def initialize(data) | |
| @type = data['body']['type'] | |
| @name = data['body']['name'] | |
| @price = data['body']['price'] | |
| @status = data['body']['status'] | |
| end |
NewerOlder