home_controller_spec.rb
1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'rails_helper'
describe HomeController, :type => :controller do
context 'actions' do
context 'index' do
describe 'Rendering' do
before :each do
get :index
end
it {is_expected.to render_template(:index)}
end
describe 'Language auto-detection' do
it 'should automatically use the language specified in the request headers' do
request.env['HTTP_ACCEPT_LANGUAGE'] = 'pt-BR'
get :index
expect(I18n.locale).to eq(:pt)
end
it 'should use a different region if still the best match' do
request.env['HTTP_ACCEPT_LANGUAGE'] = 'en-GB'
get :index
expect(I18n.locale).to eq(:en)
end
it 'should use the default language if no available language matches the requested one' do
request.env['HTTP_ACCEPT_LANGUAGE'] = 'de'
get :index
expect(I18n.locale).to eq(:en)
end
after do
I18n.locale = I18n.default_locale
end
end
end
end
context 'helpers' do
describe 'latest_repositories' do
let(:repositories) { mock }
it 'should fetch the latest content' do
Repository.expects(:latest).with(5).returns(repositories)
expect(subject.latest_repositories(5)).to be(repositories)
end
end
describe 'latest_projects' do
let(:projects) { mock }
it 'should fetch the latest content' do
Project.expects(:latest).with(5).returns(projects)
expect(subject.latest_projects(5)).to be(projects)
end
end
describe 'latest_configurations' do
let(:configurations) { mock }
it 'should fetch the latest content' do
KalibroConfiguration.expects(:latest).with(5).returns(configurations)
expect(subject.latest_configurations(5)).to be(configurations)
end
end
end
end