Skip to content

Instantly share code, notes, and snippets.

@Evshved
Last active July 12, 2018 13:29
Show Gist options
  • Save Evshved/b33e2b7639330426841ade705359c46c to your computer and use it in GitHub Desktop.
Save Evshved/b33e2b7639330426841ade705359c46c to your computer and use it in GitHub Desktop.
module StatsHelper
def stats_path
if params[:website_id].present?
website_stats_path(params[:website_id])
elsif params[:id]
organization_stats_path(params[:id])
else
all_stats_path
end
end
end
require 'rails_helper'
require 'faker'
describe StatsHelper do
describe '#stats_path' do
let(:organization_id) { FactoryBot.create(:organization).id }
let!(:params) { {id: organization_id} }
it 'return organization stats path with id of organization' do
allow(helper).to receive(:params).and_return(params)
expect(helper.stats_path).to eql("/organizations/#{organization_id}/stats")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment