Rails : i18n : unexpected redirections

In my app, I have different User types like VehicleOwner , GarageOwner, Admin and unidentified/unauthenticated. I wanted to implement localization for English and Finnish. I was successful, but suddenly all my old URLs stopped working; when I tried to access the old URLs I was redirected to login page, and the login page was also not loading – stuck on infinite redirection loop.

Continue reading

RVM Installation issue : Public Key download issue

You might have gone through the RVM installation and tried this command

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

This command actually downloads the verified public key and verifies the integrity of the installer script file.

Problem:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3

gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error

 

Solution:

Despite of that error, you execute the following command

$ \curl -sSL https://get.rvm.io | bash -s stable --ruby

# Output 

Downloading https://github.com/rvm/rvm/archive/1.27.0.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc
gpg: Signature made मंगलबार 29 मार्च 2016 using RSA key ID BF04FF17
gpg: Can't check signature: No public key
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found.
Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).

GPG signature verification failed for '/home/john/.rvm/archives/rvm-1.27.0.tgz' - 'https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc'!
try downloading the signatures:

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

or if it fails:

command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -

the key can be compared with:

https://rvm.io/mpapis.asc
 https://keybase.io/mpapis

The solution is there in the error message. Try

$ gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

If it fails, try this

$ curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -

And try this again

$ \curl -sSL https://get.rvm.io | bash -s stable --ruby

 

You are done,

Thanks for visiting

RSpect : need to be taken care of while writing UnitTesting

Ok let me show an example

let(:role) { create :role, name: 'parent' }
let(:user) { create(:user1, roles: [role]) }
let(:pact) { create :pact, parent_id: user.id, renews_at: 1.hour.ago }
let(:execution){ AutoRenewalPactAsync.new.perform}

it 'should renew pact and also schedule the drug test whose renews_at date is today' do
  expect{execution}.to change{pact.pact_years.count}.by(1)
  expect(pact.renews_at).to eq(pact.renews_at + Pact::RenewalYear)
end
------------------------------------------------------------------
Failure/Error: expect(pact.renews_at).to eq(1.year.from_now)
 
 expected: 2017-02-28 09:20:41.204897017 +0000
 got: 2016-02-28 08:20:40.980794147 +0000

Did you notice what went wrong?. Well what I was doing wrong was, I was expecting the value of stale object to be updated by the execution.

Correction:

it 'should renew pact and also schedule the drug test whose renews_at date is today' do
  expect{execution}.to change{pact.pact_years.count}.by(1)

  updated_pact = Pact.find(pact.id)
  expect(updated_pact.renews_at).to eq(pact.renews_at + Pact::RenewalYear)
end
------------------------------------------------------------------
Failure/Error: expect(updated_pact.renews_at).to eq(pact.renews_at + Pact::RenewalYear)
 
 expected: 2017-02-28 08:27:50.125348477 +0000
 got: 2017-02-28 08:27:50.125348000 +0000

This time the issue was: I was comparing the DateTime object and for them to be equal, even the milli/micro seconds have to be equal.

Correction:

updated_pact = Pact.find(pact.id)
expect(updated_pact.renews_at.to_date).to eq(pact.renews_at.to_date + Pact::RenewalYear)
should renew pact and also schedule the drug test whose renews_at date is today
Finished in 5.76 seconds (files took 5.35 seconds to load)
4 examples, 0 failures, 2 pending

 

Rails : Capybara Webkit : Issue : Multiple JS events in single example

I recently moved from Selenium Web Driver to Thoughtbot’s Capybara Webkit as JS Driver for Capybara. The main reason is, webkit is super fast in running the test suite and its headless (no browser pops up ) .

Problem I faced

I was changing the option in select box and expecting the change in span’s content. Actually some sort of calculation should have been triggered. Webkit was not triggering the ‘change‘ event properly.

Continue reading

Heroku : Rails : Compiled slug size: 325.0MB is too large

What is slug?

Slugs are compressed and pre-packaged copies of your application optimized for distribution to thedyno manager. When you git push to Heroku, your code is received by the slug compiler which transforms your repository into a slug. Scaling an application then downloads and expands the slug to a dyno for execution.

What is this error about?

It means you code base is huge and compressing it should not exceed size 300 MB; Continue reading