@@ -25,7 +25,7 @@ class ApplicationController < ActionController::Base |
||
25 | 25 |
|
26 | 26 |
def check_admin_mode |
27 | 27 |
if @config.maintenance_mode && controller_name != 'sessions' && !user_signed_in? && action_name != 'maintenance_mode' |
28 |
- redirect_to maintenance_mode_path |
|
28 |
+ render 'admin_panel/maintenance_mode' |
|
29 | 29 |
elsif !@config.maintenance_mode && !user_signed_in? && action_name == 'maintenance_mode' |
30 | 30 |
redirect_to root_path |
31 | 31 |
end |
@@ -35,7 +35,6 @@ Feature: Contact Messages |
||
35 | 35 |
Then I should see "Message sent!" |
36 | 36 |
And "admin@website.com" should receive an email with subject "Hello Webmaster" |
37 | 37 |
|
38 |
- @focus |
|
39 | 38 |
Scenario: Receive message |
40 | 39 |
Given I go to the contact page |
41 | 40 |
And I fill in "contact_message_email" with "yo@website.com" |
@@ -0,0 +1,48 @@ |
||
1 |
+@focus |
|
2 |
+Feature: Maintenance Mode |
|
3 |
+ |
|
4 |
+ In order to change things in the website |
|
5 |
+ As an admin |
|
6 |
+ I want to close the website for visitors |
|
7 |
+ |
|
8 |
+ Background: |
|
9 |
+ Given the website is configured |
|
10 |
+ |
|
11 |
+ Scenario: Enable maintenance mode |
|
12 |
+ Given I am logged in as admin |
|
13 |
+ When I go to the configurations page |
|
14 |
+ And the page should have a "input" called "info_maintenance_mode" |
|
15 |
+ Then I check the checkbox called "info_maintenance_mode" |
|
16 |
+ And I fill in "info_maintenance_title" with "Website under maintenance" |
|
17 |
+ And I fill in "info_maintenance_message" with "Please check back soon" |
|
18 |
+ And I click in the button "Update Config" |
|
19 |
+ Then I should see "Configurations saved successfully" |
|
20 |
+ And I go to the homepage |
|
21 |
+ And I should not see "Website under maintenance" |
|
22 |
+ Then I click in the link "Logout" |
|
23 |
+ And I go to the homepage |
|
24 |
+ And I should see "Website under maintenance" |
|
25 |
+ And I should see "Please check back soon" |
|
26 |
+ |
|
27 |
+ Scenario: Visitor tries to access page during maintenance mode |
|
28 |
+ Given I am not logged in |
|
29 |
+ And Maintenance mode is activated |
|
30 |
+ When I go to the blog page |
|
31 |
+ Then I should see "Website under maintenance" |
|
32 |
+ |
|
33 |
+ Scenario: User login during maintenance mode |
|
34 |
+ Given I am not logged in |
|
35 |
+ And Maintenance mode is activated |
|
36 |
+ When I log in as user |
|
37 |
+ Then I should not see "Website under maintenance" |
|
38 |
+ |
|
39 |
+ Scenario: Disable maintenance mode |
|
40 |
+ Given I am not logged in |
|
41 |
+ And Maintenance mode is activated |
|
42 |
+ When I log in as admin |
|
43 |
+ And I go to the configurations page |
|
44 |
+ And I uncheck the checkbox called "info_maintenance_mode" |
|
45 |
+ And I click in the button "Update Config" |
|
46 |
+ And I click in the link "Logout" |
|
47 |
+ And I go to the homepage |
|
48 |
+ Then I should not see "Website under maintenance" |
@@ -0,0 +1,7 @@ |
||
1 |
+Then(/^I check the checkbox called "(.*?)"$/) do |arg1| |
|
2 |
+ check(arg1) |
|
3 |
+end |
|
4 |
+ |
|
5 |
+Then(/^I uncheck the checkbox called "(.*?)"$/) do |arg1| |
|
6 |
+ uncheck(arg1) |
|
7 |
+end |
@@ -9,4 +9,8 @@ Given(/^the website is configured$/) do |
||
9 | 9 |
config.destroy |
10 | 10 |
end |
11 | 11 |
FactoryGirl.create(:info) |
12 |
-end |
|
12 |
+end |
|
13 |
+ |
|
14 |
+Given(/^Maintenance mode is activated$/) do |
|
15 |
+ Info.last.update(maintenance_mode: true, maintenance_title: 'Website under maintenance', maintenance_message: 'Please check back soon') |
|
16 |
+end |
@@ -10,10 +10,18 @@ Then(/^I log in as admin$/) do |
||
10 | 10 |
admin_login |
11 | 11 |
end |
12 | 12 |
|
13 |
+Then(/^I log in as user$/) do |
|
14 |
+ user_login |
|
15 |
+end |
|
16 |
+ |
|
13 | 17 |
Given(/^I am not logged in$/) do |
14 | 18 |
logout(:user) |
15 | 19 |
end |
16 | 20 |
|
21 |
+Then(/^I log out$/) do |
|
22 |
+ logout(:user) |
|
23 |
+end |
|
24 |
+ |
|
17 | 25 |
def user_login |
18 | 26 |
if User.find_by_first_name("John") == nil |
19 | 27 |
user = FactoryGirl.create(:user) |