Create new mission test with javascript check

James Peret 10 年之前
父节点
当前提交
4bd4677887
共有 4 个文件被更改,包括 39 次插入3 次删除
  1. 1 1
      app/models/mission.rb
  2. 3 0
      app/views/missions/show.html.erb
  3. 34 1
      features/mission_editor.feature
  4. 1 1
      features/missions_view.feature

+ 1 - 1
app/models/mission.rb

@@ -78,7 +78,7 @@ class Mission < ActiveRecord::Base
78 78
   
79 79
   def is_agent(user)
80 80
     if user
81
-      if self.mission_agents.find_all_by_user_id(user.id).count > 0
81
+      if self.mission_agents.where(user_id: user.id).count > 0
82 82
         return true
83 83
       end
84 84
     end

+ 3 - 0
app/views/missions/show.html.erb

@@ -6,6 +6,9 @@
6 6
 	<%= content_tag(:div, class: 'row') do %>
7 7
 		<%= content_tag(:div, class: 'span8 mission-briefing') do %>
8 8
 			
9
+			<%= content_tag(:h4, ((t 'mission.objective') + ':') ) %>
10
+			<%= @mission.objective.html_safe %>
11
+			
9 12
 			<%= content_tag(:h4, ((t 'mission.briefing') + ':') ) %>
10 13
 			<%= @mission.briefing.html_safe %>
11 14
 			

+ 34 - 1
features/mission_editor.feature

@@ -57,6 +57,39 @@ Feature: Mission Editor
57 57
 		And  within the ".step_form" number "1" I click in the link "Add Validation"
58 58
 		And  within the ".step_form" number "1" I click in the link "Text Validation"
59 59
 		And within the ".step-validation" number "4" I fill in "Validation description" with "What is your ETA?"
60
+		And I click in the link "Add a step"
61
+		Then within the ".step_form" number "3" I click in the link "Step"
62
+		And within the ".step_form" number "3" I fill in "Step Title" with "Go to the last station"
63
+		And within the ".step_form" number "3" I fill in "Description" with "Stay in the train ultil it reaches the last station in the line. Get out of the train"
64
+		And I click in the link "Add a step"
65
+		Then within the ".step_form" number "4" I click in the link "Step"
66
+		And within the ".step_form" number "4" I fill in "Step Title" with "Wait for the pickup"
67
+		And within the ".step_form" number "4" I fill in "Description" with "Somebody is gonna come and take you to the next checkpoint"
60 68
 		And I click in the button "Save Agent"
61 69
 		Then within "h1" I should see "Agents"
62
-		And I should see "Treasure Hunter"
70
+		And I should see "Treasure Hunter"
71
+		And I click in the link "Next"
72
+		Then within "h1" I should see "Launch Mission"
73
+		And I click in the link "Review Mission"
74
+		Then within "h1" I should see "Treaure Hunt"
75
+		And I should see "Planning"
76
+		And I should see "Follow the steps to find the treasure."
77
+		And I should see "Hello, welcome to the Treasure Hunt Mission!"
78
+		And I should see "Chocolate Bar"
79
+		And within ".mission-director-name" I should see "John Doe"
80
+		Then within "#mission-tabs-nav" I click in the link "Agents"
81
+		And I should see "Treasure Hunter"
82
+		And I should see "Planning"
83
+		And I should see "Follow the step to find the treasure."
84
+		And I should see "Go to the train station"
85
+		And I should see "Get the first train"
86
+		And I should not see "Go to the last station"
87
+		And I should not see "Wait for the pickup"
88
+		Then I click in the link "Edit Mission"
89
+		And within "h1" I should see "Launch Mission"
90
+		And I click in the link "Launch Mission"
91
+		Then within "h1" I should see "Treaure Hunt"
92
+		And I should see "Launched"
93
+		And within ".mission-timer" I should see "5"
94
+		And I should see "Days remaining"
95
+		And within ".mission-director-name" I should see "John Doe"

+ 1 - 1
features/missions_view.feature

@@ -1,4 +1,4 @@
1
-@mission_view
1
+@mission_view 
2 2
 Feature: Missions
3 3
 	In order to browse for missions
4 4
 	As an Avalanche Agent