Commit f0955bafc9c0524fe1f5bf492697cbc23e400f11

Authored by Diego Araújo
Committed by Rafael Reggiani Manzo
1 parent 610763c4
Exists in colab and in 2 other branches master, stable

Fix cache creation on homepage

As we are using multiple cache fragments for one action, we need to
specify action_suffixes so rails create different keys for each
fragment.

Signed-off-by: Rafael Reggiani Manzo <rr.manzo@protonmail.com>
app/views/home/index.html.erb
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 <h2><%= t('latest_projects') %></h2> 12 <h2><%= t('latest_projects') %></h2>
13 13
14 <ul> 14 <ul>
15 - <% cache do %> 15 + <% cache action_suffix: 'latest_projects' do %>
16 <% @latest_projects.each do |project| %> 16 <% @latest_projects.each do |project| %>
17 <li><%= link_to(project.name, project_path(project.id)) %></li> 17 <li><%= link_to(project.name, project_path(project.id)) %></li>
18 <% end %> 18 <% end %>
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 <h2><%= t('latest_repositories') %></h2> 23 <h2><%= t('latest_repositories') %></h2>
24 24
25 <ul> 25 <ul>
26 - <% cache do %> 26 + <% cache action_suffix: 'latest_repositories' do %>
27 <% @latest_repositories.each do |repository| %> 27 <% @latest_repositories.each do |repository| %>
28 <li><%= link_to(repository.name, repository_path(repository.id)) %></li> 28 <li><%= link_to(repository.name, repository_path(repository.id)) %></li>
29 <% end %> 29 <% end %>
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 <h2><%= t('latest_configurations') %></h2> 34 <h2><%= t('latest_configurations') %></h2>
35 35
36 <ul> 36 <ul>
37 - <% cache do %> 37 + <% cache action_suffix: 'latest_configurations' do %>
38 <% @latest_configurations.each do |configuration| %> 38 <% @latest_configurations.each do |configuration| %>
39 <li><%= link_to(configuration.name, kalibro_configuration_path(configuration.id)) %></li> 39 <li><%= link_to(configuration.name, kalibro_configuration_path(configuration.id)) %></li>
40 <% end %> 40 <% end %>
features/homepage.feature
@@ -3,7 +3,9 @@ Feature: Homepage @@ -3,7 +3,9 @@ Feature: Homepage
3 As a regular user 3 As a regular user
4 I want to have in one page useful links to manage my account and session 4 I want to have in one page useful links to manage my account and session
5 5
  6 + @kalibro_processor_restart
6 Scenario: Before signing in 7 Scenario: Before signing in
  8 + Given I have a project named "GCC"
7 Then I am at the homepage 9 Then I am at the homepage
8 And I should see "Home" 10 And I should see "Home"
9 And I should see "Project" 11 And I should see "Project"
@@ -16,6 +18,7 @@ Feature: Homepage @@ -16,6 +18,7 @@ Feature: Homepage
16 And I should see "Latest projects" 18 And I should see "Latest projects"
17 And I should see "Latest repositories" 19 And I should see "Latest repositories"
18 And I should see "Latest configurations" 20 And I should see "Latest configurations"
  21 + Then I should see "GCC" only "1" times
19 22
20 Scenario: Signed in 23 Scenario: Signed in
21 Given I am a regular user 24 Given I am a regular user
features/step_definitions/homepage_steps.rb
@@ -12,4 +12,8 @@ end @@ -12,4 +12,8 @@ end
12 12
13 Then(/^I should see "(.+)"$/) do |text| 13 Then(/^I should see "(.+)"$/) do |text|
14 expect(page).to have_content(text) 14 expect(page).to have_content(text)
15 -end  
16 \ No newline at end of file 15 \ No newline at end of file
  16 +end
  17 +
  18 +Then(/^I should see "(.*?)" only "(.*?)" times$/) do |text, times|
  19 + expect(page).to have_content(text, count: times.to_i)
  20 +end