Giter VIP home page Giter VIP logo

currency's Introduction

README

Project for get currency course (USD/RUB) online, and auto refresh on page in opened window without reload page In Admin section you may freeze course with timer

For test project need to start separatly, after bundle and rails db:setup

  1. rake resque:scheduler
  2. QUEUE=* rake resque:work
  3. hivemind Procfile.dev

Resque web interface accesed by this address http://localhost:5000/resque/schedule

  • Ruby version 3.0.3
  • Database creation rails db:create
  • Database initialization rails db:migrate
  • How to run the test suite

Issue:

  1. dinamically created jobs not worked

currency's People

Contributors

apilot avatar

Watchers

 avatar

currency's Issues

Code review

  1. Нету тестов. Те что есть не проверяют ничего.
RSpec.describe "GetCurrency" do
  let(:uri) { URI('https://test.com/return_json/reviews.json') }
  let(:data) { {"reviews" => [{"Valute" => { "USD" => {"value" => 60.2 } }, "data2"=> "2"}]} }
  require_relative "../../../lib/modules/get_currency"
  it "return data from url" do
    data = GetCurrency.get_course
    data
  end
end

let(:data) - объявили data через let и дальше происходит перезапись data = GetCurrency.get_course. Изначальный хеш из let(:data) в итоге не использован.
Предлагаю попробовать переписать тест примерно так:

it "return data from url" do
    expect(GetCurrency.get_course).to eq(data)
  end

(Скорее всего не будет работать, потому что курс постоянно меняется. С этим может помочь либа и п.2)
2. https://github.com/vcr/vcr - С помощью этого гема можно записывать HTTP запросы в сторонние сервисы. В данном проекте мы может это сделать для https://www.cbr-xml-daily.ru/daily_json.js
3. views - в целом ок, но сейчас в новых проектах достаточно редко используется erb. Зачастую Rails идет в качестве API сервера и не отвечает за FrontEnd.
4. Для отложенных джоб советую рассмотреть еще Sidekiq.
5. GetCurrency: @source - можно сделать константой; @current - не нашел использования
6. GetCurrency: Расположение в lib - ok, так как он связывается с внешним API и отдает текущий курс
7. ApplicationService: def self.call - так иногда делают, но в больших проектах это может оказаться проблемой. Стоит явно вызывать new.
8. CreateService: tx_and_commit - тут всего одна операция в транзакции, она и так будет атомарной, post_call можно явно вызвать. Выглядит избыточно, по крайней мере для такого маленького проекта.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.