Rewards controller scaffolding and layouts

James Peret vor 10 Jahren
Ursprung
Commit
e41a9c3965

+ 12 - 1
app/assets/stylesheets/avalanche_theme.css.less

@@ -280,4 +280,15 @@ h4 {
280 280
 .centered {
281 281
 	margin-left: auto;
282 282
 	margin-right: auto;
283
-}
283
+	text-align: center;
284
+}
285
+
286
+.spacer-top-small    { margin-top:    25px; }
287
+.spacer-left-small   { margin-left:   25px; }
288
+.spacer-right-small  { margin-right:  25px; }
289
+.spacer-bottom-small { margin-bottom: 25px; }
290
+
291
+.spacer-top-medium    { margin-top:    50px; }
292
+.spacer-left-medium   { margin-left:   50px; }
293
+.spacer-right-medium  { margin-right:  50px; }
294
+.spacer-bottom-medium { margin-bottom: 50px; }

+ 1 - 0
app/assets/stylesheets/avl2_theme/colors.less

@@ -44,6 +44,7 @@
44 44
 @border-width: 2px;
45 45
 
46 46
 @theme-border: 2px solid @medium-gray;
47
+@theme-border-radius: 4px;
47 48
 
48 49
 .theme-box-padding { padding: 8px; padding-right: 18px; padding-left: 18px; }
49 50
 

+ 25 - 1
app/assets/stylesheets/mission_editor.css.less

@@ -105,4 +105,28 @@ span.btn-file .form-group {
105 105
 }
106 106
 .sidebar { margin-top: -28px; }
107 107
 .sidebar .panel-content { margin-top: 2px;}
108
-.sidebar .panel-body { margin-top: -28px; }
108
+.sidebar .panel-body { margin-top: -28px; }
109
+
110
+.mission-editor-reward-list {
111
+	margin-left: 0px;
112
+	list-style: none;
113
+	.editor-reward {
114
+		height: 280px;
115
+		border: @theme-border;
116
+		border-radius: @theme-border-radius;
117
+		background-color: @white;
118
+		.theme-box-padding
119
+	}
120
+	.editor-reward-new {
121
+		height: 296px;
122
+		border: 2px dashed #AFB4BF;
123
+		border-radius: 10px;
124
+		text-align: center;
125
+		i { font-size: 230px; color: #AFB4BF; }
126
+	}
127
+	.centered-editor-new {
128
+		width: 350px;
129
+		margin-left: auto;
130
+		margin-right: auto;
131
+	}
132
+}

+ 1 - 1
app/controllers/missions_controller.rb

@@ -58,7 +58,7 @@ class MissionsController < ApplicationController
58 58
     @mission.owner = current_user
59 59
     respond_to do |format|
60 60
       if @mission.save
61
-        format.html { redirect_to mission_control_path(@mission), notice: 'Mission was successfully created.' }
61
+        format.html { redirect_to mission_editor_rewards_list(@mission), notice: 'Mission was successfully created.' }
62 62
         format.json { render action: 'show', status: :created, location: @mission }
63 63
       else
64 64
         format.html { render action: 'new' }

+ 74 - 0
app/controllers/rewards_controller.rb

@@ -0,0 +1,74 @@
1
+class RewardsController < ApplicationController
2
+  before_action :set_reward, only: [:edit, :update, :destroy]
3
+  before_action :set_mission
4
+
5
+  # GET /rewards
6
+  # GET /rewards.json
7
+  def index
8
+    @rewards = Reward.where(mission: @mission)
9
+  end
10
+
11
+  # GET /rewards/new
12
+  def new
13
+    @reward = Reward.new
14
+  end
15
+
16
+  # GET /rewards/1/edit
17
+  def edit
18
+  end
19
+
20
+  # POST /rewards
21
+  # POST /rewards.json
22
+  def create
23
+    @reward = Reward.new(reward_params)
24
+
25
+    respond_to do |format|
26
+      if @reward.save
27
+        format.html { redirect_to @reward, notice: 'Reward was successfully created.' }
28
+        format.json { render action: 'show', status: :created, location: @reward }
29
+      else
30
+        format.html { render action: 'new' }
31
+        format.json { render json: @reward.errors, status: :unprocessable_entity }
32
+      end
33
+    end
34
+  end
35
+
36
+  # PATCH/PUT /rewards/1
37
+  # PATCH/PUT /rewards/1.json
38
+  def update
39
+    respond_to do |format|
40
+      if @reward.update(reward_params)
41
+        format.html { redirect_to @reward, notice: 'Reward was successfully updated.' }
42
+        format.json { head :no_content }
43
+      else
44
+        format.html { render action: 'edit' }
45
+        format.json { render json: @reward.errors, status: :unprocessable_entity }
46
+      end
47
+    end
48
+  end
49
+
50
+  # DELETE /rewards/1
51
+  # DELETE /rewards/1.json
52
+  def destroy
53
+    @reward.destroy
54
+    respond_to do |format|
55
+      format.html { redirect_to rewards_url }
56
+      format.json { head :no_content }
57
+    end
58
+  end
59
+
60
+  private
61
+    # Use callbacks to share common setup or constraints between actions.
62
+    def set_reward
63
+      @reward = Reward.find(params[:id])
64
+    end
65
+    
66
+    def set_mission
67
+       @mission = Mission.friendly.find(params[:id])
68
+    end
69
+
70
+    # Never trust parameters from the scary internet, only allow the white list through.
71
+    def reward_params
72
+      params[:reward]
73
+    end
74
+end

+ 2 - 0
app/helpers/rewards_helper.rb

@@ -0,0 +1,2 @@
1
+module RewardsHelper
2
+end

+ 6 - 1
app/views/missions/_form.html.erb

@@ -21,7 +21,12 @@
21 21
   <% end %>
22 22
   <%= content_tag(:div, class: "form-submit-center") do %>
23 23
   	<%= content_tag(:p) do %>
24
-  		<%= f.submit (t 'mission_editor.save_and_continue'), class: 'btn btn-large btn-success all-caps' %>
24
+		<% if params[:action] == 'edit' %>
25
+			<%= f.submit (t 'mission_editor.save'), class: 'btn btn-large btn-success spacer-left-small' %>
26
+			<%= link_to((t'nav.next'), rewards_path(@mission), class: 'btn ')%>
27
+		<% else%>
28
+  			<%= f.submit (t 'mission_editor.save_and_continue'), class: 'btn btn-large btn-success all-caps' %>
29
+		<% end %>
25 30
 	<% end %>
26 31
 	<%= content_tag(:p) do %>
27 32
 		<%= link_to 'cancel', missions_path, class: 'btn btn-link btn-danger' %>

+ 28 - 0
app/views/missions/_mission_editor_tabs.html.erb

@@ -0,0 +1,28 @@
1
+<%= content_tag(:div, class: 'container top-container ') do %>
2
+	<%= content_tag(:div, class: 'row') do %>
3
+		<%= content_tag(:div, class: 'span12') do %>
4
+			<%= content_tag(:div, class: 'mission-editor-page-counter') do %>
5
+				<%= content_tag(:div, '', class: 'line')%>
6
+				
7
+				<%= content_tag(:ul, class: 'steps') do %>
8
+					<%= content_tag(:li, class: 'step') do %>
9
+						<%= content_tag(:div, '1', class: 'circle current') %><br>
10
+						<%= content_tag(:div, (t 'mission_editor.mission_details'), class: 'description current') %>
11
+					<% end %>
12
+					<%= content_tag(:li, class: 'step') do %>
13
+						<%= content_tag(:div, '2', class: 'circle') %><br>
14
+						<%= content_tag(:div, (t 'mission_editor.rewards'), class: 'description') %>
15
+					<% end %>
16
+					<%= content_tag(:li, class: 'step') do %>
17
+						<%= content_tag(:div, '3', class: 'circle') %><br>
18
+						<%= content_tag(:div, (t 'mission_editor.agents'), class: 'description') %>
19
+					<% end %>
20
+					<%= content_tag(:li, class: 'step') do %>
21
+						<%= content_tag(:div, '4', class: 'circle') %><br>
22
+						<%= content_tag(:div, (t 'mission_editor.launch'), class: 'description') %>
23
+					<% end %>
24
+				<% end %>
25
+			<% end %>
26
+		<% end %>
27
+	<% end %>		
28
+<% end %>

+ 41 - 16
app/views/missions/edit.html.erb

@@ -1,21 +1,46 @@
1
-<%= content_tag(:div, class: 'container top-container container-last') do %>
2
-	<%= content_tag(:div, class: 'row') do %>
3
-		<%= content_tag(:div, class: 'span12') do %>
4
-
5
-			<%= content_tag(:div, class: 'page-header page-header-type') do %>
6
-				<%= content_tag(:small, (t 'mission.edit_mission')+':') %>
7
-				<%= content_tag(:h1) do %>
8
-					<%=  @mission.title %>
9
-					<%= link_to (t 'nav.back'), mission_control_path(@mission), class: 'btn btn-mini' %>
10
-					<%= status(@mission.status) %>
11
-				<% end %>
12
-			<% end %>
1
+<%= render :partial => 'mission_editor_tabs' %>
13 2
 
14
-			<%= render 'form' %>
15 3
 
16
-			<%= link_to 'Show', @mission %> |
17
-			<%= link_to 'Back', missions_path %>
4
+
5
+<%= content_tag(:div, class: 'container-bg') do %>
6
+	<%= content_tag(:div, class: 'container container-bg mission-detail-container') do %>
7
+		<%= content_tag(:div, class: 'row') do %>
8
+			<%= content_tag(:div, class: 'span12') do %>
9
+				
10
+				<%= content_tag(:div, class: 'page-header page-header-type') do %>
11
+					<%= content_tag(:small, @mission.title + ':') %>
12
+					<%= content_tag(:h1) do %>
13
+						<%= t 'mission.edit_mission_details' %>
14
+					<% end %>
15
+				<% end %>
16
+				
17
+			<% end%>
18
+		<% end %>
19
+		<%= content_tag(:div, class: 'row') do %>
20
+			<%= content_tag(:div, class: 'span8') do %>
21
+			
22
+				<%= render 'form' %>
23
+			
24
+			<% end %>
25
+			<% # Sidebar %>
26
+			<%= content_tag(:div, class: 'span4 sidebar') do %>
27
+			     <%= content_tag(:div, class: 'panel panel-default sidebar-carret') do %>
28
+			     	<%= content_tag(:div, class: 'panel-body white-bg') do %>
29
+				   		<%= content_tag(:div, class: "panel-content") do %>
30
+				   			<%= content_tag(:div, class: "panel-text") do %>
31
+								<%= content_tag(:h3, (t 'mission_editor.mission_details_help_title')) %>
32
+								<%= content_tag(:div, (t 'mission_editor.mission_details_help').html_safe, class: 'small-text') %>
33
+							<% end %>
34
+						<% end %>
35
+					<% end %>
36
+				<% end %>
37
+			<% end %>
18 38
 			
19 39
 		<% end %>
20
-	<% end %>		
40
+	<% end %>			
21 41
 <% end %>
42
+
43
+
44
+
45
+
46
+

+ 2 - 29
app/views/missions/new.html.erb

@@ -1,31 +1,5 @@
1
-<%= content_tag(:div, class: 'container top-container ') do %>
2
-	<%= content_tag(:div, class: 'row') do %>
3
-		<%= content_tag(:div, class: 'span12') do %>
4
-			<%= content_tag(:div, class: 'mission-editor-page-counter') do %>
5
-				<%= content_tag(:div, '', class: 'line')%>
6
-				
7
-				<%= content_tag(:ul, class: 'steps') do %>
8
-					<%= content_tag(:li, class: 'step') do %>
9
-						<%= content_tag(:div, '1', class: 'circle current') %><br>
10
-						<%= content_tag(:div, (t 'mission_editor.mission_details'), class: 'description current') %>
11
-					<% end %>
12
-					<%= content_tag(:li, class: 'step') do %>
13
-						<%= content_tag(:div, '2', class: 'circle') %><br>
14
-						<%= content_tag(:div, (t 'mission_editor.rewards'), class: 'description') %>
15
-					<% end %>
16
-					<%= content_tag(:li, class: 'step') do %>
17
-						<%= content_tag(:div, '3', class: 'circle') %><br>
18
-						<%= content_tag(:div, (t 'mission_editor.agents'), class: 'description') %>
19
-					<% end %>
20
-					<%= content_tag(:li, class: 'step') do %>
21
-						<%= content_tag(:div, '4', class: 'circle') %><br>
22
-						<%= content_tag(:div, (t 'mission_editor.launch'), class: 'description') %>
23
-					<% end %>
24
-				<% end %>
25
-			<% end %>
26
-		<% end %>
27
-	<% end %>		
28
-<% end %>
1
+<%= render :partial => 'mission_editor_tabs' %>
2
+
29 3
 
30 4
 
31 5
 <%= content_tag(:div, class: 'container-bg') do %>
@@ -36,7 +10,6 @@
36 10
 				<%= content_tag(:div, class: 'page-header') do %>
37 11
 					<%= content_tag(:h1) do %>
38 12
 						<%= t 'mission.create_mission' %> 
39
-						<%= link_to (t 'nav.back'), missions_path, class: 'btn btn-mini' %>
40 13
 					<% end %>
41 14
 				<% end %>
42 15
 				

+ 57 - 0
app/views/rewards/_form.html.erb

@@ -0,0 +1,57 @@
1
+<%= bootstrap_form_for(@reward) do |f| %>
2
+ <%= f.alert_message "Please fix the errors below." %>
3
+
4
+  <div class="form-inputs">
5
+  </div>
6
+
7
+  <div class="form-actions">
8
+    <%= f.submit %>
9
+  </div>
10
+<% end %>
11
+
12
+
13
+<%= bootstrap_form_for(@reward) do |f| %>
14
+  <%= f.alert_message "Please fix the errors below." %>
15
+  <%= content_tag(:div, class: 'panel panel-default') do %>
16
+  	<%= content_tag(:div, class: 'panel-body white-bg') do %>
17
+		<%= content_tag(:div, class: "panel-content") do %>
18
+			<%= content_tag(:div, class: "panel-text") do %>
19
+				<%= content_tag(:div, class: "form-inputs") do %>
20
+				    <%= f.text_field :title, label: (t 'mission_editor.reward_title'), class: 'input-block-level' %>
21
+				    <%= f.text_area :description, label: (t 'mission_editor.reward_description'), class: 'input-block-level', rows: 5 %>
22
+				    
23
+					
24
+					<%= content_tag(:div, class: 'form-group', style: 'padding-bottom: 2px;') do %>
25
+						<%= content_tag(:label, (t 'mission_editor.cover_image'), class: 'control-label', for: 'cover_image')%>
26
+						<%= content_tag(:div, class: 'fileupload fileupload-new', data: { provides: 'fileupload' } ) do %>
27
+							<%= content_tag(:div, class: 'fileupload-preview cover-fileupload-preview thumbnail', data: { trigger: 'fileinput' } ) do %>
28
+								<%= image_tag @reward.img.to_s if @reward.img? %>
29
+							<% end %>
30
+							<%= content_tag(:span, class: 'btn btn-default btn-file btn-mini pull-right', style: 'padding-top: 0px; padding-bottom: 0px;') do %>
31
+								<%= content_tag(:span, '', class: 'fileinput-new') %>
32
+								<%= content_tag(:span, '', class: 'fileinput-exists') %>
33
+
34
+								<%= f.file_field :img, class: 'hidden ', layout: :inline,  label: (t 'mission_editor.select_image') %>
35
+							<% end %>
36
+						<% end %>
37
+					<% end %>
38
+					
39
+					
40
+				<% end %>
41
+			<% end %>
42
+		<% end %>
43
+	<% end %>
44
+  <% end %>
45
+  <%= content_tag(:div, class: "form-submit-center") do %>
46
+  	<%= content_tag(:p) do %>
47
+		<% if params[:action] == 'edit' %>
48
+			<%= f.submit (t 'mission_editor.save_reward'), class: 'btn btn-large btn-success spacer-left-small' %>
49
+		<% else%>
50
+  			<%= f.submit (t 'mission_editor.create_reward'), class: 'btn btn-large btn-success all-caps' %>
51
+		<% end %>
52
+	<% end %>
53
+	<%= content_tag(:p) do %>
54
+		<%= link_to 'back', missions_path, class: 'btn btn-link btn-danger' %>
55
+	<% end %>
56
+  <% end %>
57
+<% end %>

+ 6 - 0
app/views/rewards/edit.html.erb

@@ -0,0 +1,6 @@
1
+<h1>Editing reward</h1>
2
+
3
+<%= render 'form' %>
4
+
5
+<%= link_to 'Show', @reward %> |
6
+<%= link_to 'Back', rewards_path %>

+ 66 - 0
app/views/rewards/index.html.erb

@@ -0,0 +1,66 @@
1
+<%= render :partial => 'missions/mission_editor_tabs' %>
2
+
3
+<%= content_tag(:div, class: 'container-bg') do %>
4
+	<%= content_tag(:div, class: 'container container-bg mission-detail-container') do %>
5
+		<%= content_tag(:div, class: 'row') do %>
6
+			<%= content_tag(:div, class: 'span12') do %>
7
+			
8
+				<%= content_tag(:div, class: 'page-header page-header-type') do %>
9
+					<%= content_tag(:small, @mission.title + ':') %>
10
+					<%= content_tag(:h1) do %>
11
+						<%= t 'mission.editor.rewards' %>
12
+					<% end %>
13
+				<% end %>
14
+				
15
+			<% end%>
16
+		<% end %>
17
+		<%= content_tag(:div, class: 'row') do %>
18
+			<%= content_tag(:ul, class: 'mission-editor-reward-list') do %>
19
+			     <% @rewards.each do |reward| %>
20
+					<%= content_tag(:li, class: 'span4') do %>
21
+						<%= content_tag(:div, class: 'editor-reward') do %>
22
+							<%= content_tag(:div,  class: 'reward-image ') do %>
23
+								<%= image_tag reward.img %><br>
24
+								<%= content_tag(:p, content_tag(:small, reward.title)) %>
25
+							<% end %>
26
+							<%= content_tag(:p, reward.description) %>
27
+							<%= content_tag(:p, class: 'rewards-details ') do %>
28
+								<%= content_tag(:span, (t 'mission.agents')+': ', class: 'reward-agent-title') %>
29
+								<% agent_counter = 1 %>
30
+								<% reward.mission_agents.each do |agent| %>		
31
+									<%= content_tag(:span, (link_to agent.role.to_s, mission_agent_details_path(agent: agent.id, id: agent.mission)) , class: 'reward-agent-role') %>
32
+									<% if agent_counter < reward.mission_agents.count %>
33
+										<%= ', ' %>
34
+									<% end %>
35
+									<% agent_counter = agent_counter + 1 %>
36
+								<% end %>
37
+							<% end %>
38
+						<% end %>
39
+					<% end %>
40
+				<% end %>
41
+				<% @rewards.count == 0 ? centered = ['span12', 'centered-editor-new'] : centered = ['span4', ''] %>
42
+				<%= content_tag(:li, class: centered[0] ) do %>
43
+					<%= content_tag(:div, class: "editor-reward-new #{centered[1]}") do %>
44
+						<i class="icon-reward"></i><br>
45
+						<%= link_to 'Add Reward', new_reward_path(@mission), class: 'btn' %>
46
+					<% end %>
47
+				<% end %>
48
+			<% end %>
49
+		<% end %>
50
+		<%= content_tag(:div, class: 'row') do %>
51
+			<%= content_tag(:div, class: 'span12') do %>
52
+			     <%= content_tag(:div, class: "form-submit-center") do %>
53
+			     	<%= content_tag(:p) do %>
54
+						<%= link_to (t'nav.back'), edit_mission_path(@mission), class: 'btn spacer-right-small' %>
55
+						<%= link_to((t'nav.next'), '#', class: 'btn btn-success')%>
56
+					<% end %>
57
+					<%= content_tag(:p) do %>
58
+						<%= link_to 'cancel', missions_path, class: 'btn btn-link btn-danger' %>
59
+					<% end %>
60
+				<% end %>
61
+			<% end %>
62
+		<% end %>
63
+		
64
+		
65
+	<% end %>			
66
+<% end %>

+ 4 - 0
app/views/rewards/index.json.jbuilder

@@ -0,0 +1,4 @@
1
+json.array!(@rewards) do |reward|
2
+  json.extract! reward, :id
3
+  json.url reward_url(reward, format: :json)
4
+end

+ 42 - 0
app/views/rewards/new.html.erb

@@ -0,0 +1,42 @@
1
+<% title "#{t 'mission_editor.add_reward'} - #{@config.website_name}" %>
2
+
3
+<%= render :partial => 'missions/mission_editor_tabs' %>
4
+
5
+<%= content_tag(:div, class: 'container-bg') do %>
6
+	<%= content_tag(:div, class: 'container container-bg mission-detail-container') do %>
7
+		<%= content_tag(:div, class: 'row') do %>
8
+			<%= content_tag(:div, class: 'span12') do %>
9
+				
10
+				<%= content_tag(:div, class: 'page-header page-header-type') do %>
11
+					<%= content_tag(:small, @mission.title + ':') %>
12
+					<%= content_tag(:h1) do %>
13
+						<%= t 'mission_editor.add_reward' %>
14
+					<% end %>
15
+				<% end %>
16
+				
17
+			<% end%>
18
+		<% end %>
19
+		<%= content_tag(:div, class: 'row') do %>
20
+			<%= content_tag(:div, class: 'span8') do %>
21
+			
22
+				<%= render 'form' %>
23
+				<%= link_to 'Back', rewards_path(@mission) %>
24
+			
25
+			<% end %>
26
+			<% # Sidebar %>
27
+			<%= content_tag(:div, class: 'span4 sidebar') do %>
28
+			     <%= content_tag(:div, class: 'panel panel-default sidebar-carret') do %>
29
+			     	<%= content_tag(:div, class: 'panel-body white-bg') do %>
30
+				   		<%= content_tag(:div, class: "panel-content") do %>
31
+				   			<%= content_tag(:div, class: "panel-text") do %>
32
+								<%= content_tag(:h3, (t 'mission_editor.mission_details_help_title')) %>
33
+								<%= content_tag(:div, (t 'mission_editor.mission_details_help').html_safe, class: 'small-text') %>
34
+							<% end %>
35
+						<% end %>
36
+					<% end %>
37
+				<% end %>
38
+			<% end %>
39
+			
40
+		<% end %>
41
+	<% end %>			
42
+<% end %>

+ 4 - 0
app/views/rewards/show.html.erb

@@ -0,0 +1,4 @@
1
+<p id="notice"><%= notice %></p>
2
+
3
+<%= link_to 'Edit', edit_reward_path(@reward) %> |
4
+<%= link_to 'Back', rewards_path %>

+ 1 - 0
app/views/rewards/show.json.jbuilder

@@ -0,0 +1 @@
1
+json.extract! @reward, :id, :created_at, :updated_at

+ 1 - 0
config/locales/mission.en.yml

@@ -15,6 +15,7 @@ en:
15 15
     dashboard: 'Dashboard'
16 16
     account: 'Account'
17 17
   mission_editor:
18
+    save: 'Save'
18 19
     save_and_continue: 'Save & Continue'
19 20
     select_image: 'Select Image'
20 21
     language: 'Language'

+ 1 - 0
config/locales/mission.pt-BR.yml

@@ -15,6 +15,7 @@ pt-BR:
15 15
     dashboard: 'Painel'
16 16
     account: 'Conta'
17 17
   mission_editor:
18
+    save: 'Salvar'
18 19
     save_and_continue: 'Salvar & Continuar'
19 20
     select_image: 'Select Image'
20 21
     language: 'Lingua'

+ 13 - 2
config/routes.rb

@@ -31,8 +31,19 @@ Avalanche2::Application.routes.draw do
31 31
   
32 32
   # Mission Control
33 33
   get 'missions/:id/mission_control' => 'missions#mission_control', as: :mission_control
34
-  get  'missions/:id/mission_control/accept_step_submission/:step_submission_id' => 'missions#accept_step_submission', as: :accept_step_submission
35
-  get  'missions/:id/mission_control/reject_step_submission/:step_submission_id' => 'missions#reject_step_submission', as: :reject_step_submission
34
+  get 'missions/:id/mission_control/accept_step_submission/:step_submission_id' => 'missions#accept_step_submission', as: :accept_step_submission
35
+  get 'missions/:id/mission_control/reject_step_submission/:step_submission_id' => 'missions#reject_step_submission', as: :reject_step_submission
36
+  
37
+  # Mission Editor
38
+  get    'missions/:id/editor' => 'missions#edit', as: :mission_editor
39
+  resources :rewards, path: 'missions/:id/editor/rewards'
40
+  # get    'missions/:id/editor/rewards' => 'rewards#index', as: :mission_editor_rewards_list
41
+  # get    'missions/:id/editor/rewards/new' => 'rewards#new', as: :mission_editor_new_reward
42
+  # post   'missions/:id/editor/rewards/create' => 'rewards#create', as: :mission_editor_create_reward
43
+  # get    'missions/:id/editor/rewards/:reward/edit' => 'rewards#edit', as: :mission_editor_edit_reward
44
+  # post   'missions/:id/editor/rewards/:reward/update' => 'rewards#update', as: :mission_editor_update_reward
45
+  # delete 'missions/:id/editor/rewards/:reward/destroy' => 'rewards#destroy', as: :mission_editor_delete_reward
46
+  
36 47
   
37 48
   # Agents
38 49
   get 'dashboard' => 'agents#dashboard', as: :dashboard

+ 49 - 0
test/controllers/rewards_controller_test.rb

@@ -0,0 +1,49 @@
1
+require 'test_helper'
2
+
3
+class RewardsControllerTest < ActionController::TestCase
4
+  setup do
5
+    @reward = rewards(:one)
6
+  end
7
+
8
+  test "should get index" do
9
+    get :index
10
+    assert_response :success
11
+    assert_not_nil assigns(:rewards)
12
+  end
13
+
14
+  test "should get new" do
15
+    get :new
16
+    assert_response :success
17
+  end
18
+
19
+  test "should create reward" do
20
+    assert_difference('Reward.count') do
21
+      post :create, reward: {  }
22
+    end
23
+
24
+    assert_redirected_to reward_path(assigns(:reward))
25
+  end
26
+
27
+  test "should show reward" do
28
+    get :show, id: @reward
29
+    assert_response :success
30
+  end
31
+
32
+  test "should get edit" do
33
+    get :edit, id: @reward
34
+    assert_response :success
35
+  end
36
+
37
+  test "should update reward" do
38
+    patch :update, id: @reward, reward: {  }
39
+    assert_redirected_to reward_path(assigns(:reward))
40
+  end
41
+
42
+  test "should destroy reward" do
43
+    assert_difference('Reward.count', -1) do
44
+      delete :destroy, id: @reward
45
+    end
46
+
47
+    assert_redirected_to rewards_path
48
+  end
49
+end

+ 4 - 0
test/helpers/rewards_helper_test.rb

@@ -0,0 +1,4 @@
1
+require 'test_helper'
2
+
3
+class RewardsHelperTest < ActionView::TestCase
4
+end