File tree Expand file tree Collapse file tree 8 files changed +40
-7
lines changed
Expand file tree Collapse file tree 8 files changed +40
-7
lines changed Original file line number Diff line number Diff line change 6464group :test do
6565 # Needed for TravisCI
6666 gem 'rake'
67- gem "database_cleaner"
67+
68+ # Do not upgrade until
69+ # https://github.com/DatabaseCleaner/database_cleaner/issues/317 is fixed
70+ gem "database_cleaner" , '1.3.0'
71+
6872 gem 'shoulda' , ">= 3.5"
6973 gem 'fabrication'
7074 gem 'faker'
Original file line number Diff line number Diff line change 111111 concurrent-ruby (1.0.1 )
112112 daemons (1.1.9 )
113113 dalli (2.7.2 )
114- database_cleaner (1.4 .0 )
114+ database_cleaner (1.3 .0 )
115115 debug_inspector (0.0.2 )
116116 devise (3.5.6 )
117117 bcrypt (~> 3.0 )
@@ -360,7 +360,7 @@ DEPENDENCIES
360360 capybara (~> 2.4.4 )
361361 coffee-rails
362362 dalli
363- database_cleaner
363+ database_cleaner ( = 1.3.0 )
364364 devise (= 3.5.6 )
365365 dotenv-rails
366366 elasticsearch-model
Original file line number Diff line number Diff line change 11class TransfersController < ApplicationController
22 def create
33 @source = find_source
4- Transfer . create ( transfer_params . merge source : @source )
54 @account = Account . find ( transfer_params [ :destination ] )
5+ transfer = Transfer . new (
6+ transfer_params . merge ( source : @source , destination : @account )
7+ )
8+
9+ begin
10+ transfer . save!
11+ rescue ActiveRecord ::RecordInvalid
12+ flash [ :error ] = transfer . errors . full_messages . to_sentence
13+ end
614 redirect_to redirect_target
715 end
816
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ class Transfer < ActiveRecord::Base
1717 belongs_to :operator , class_name : "User"
1818 has_many :movements
1919
20+ validate :different_source_and_destination
21+
2022 after_create :make_movements
2123
2224 def make_movements
@@ -39,4 +41,9 @@ def source_id
3941 def destination_id
4042 destination . respond_to? ( :id ) ? destination . id : destination
4143 end
44+
45+ def different_source_and_destination
46+ return unless source == destination
47+ errors . add ( :base , :same_account )
48+ end
4249end
Original file line number Diff line number Diff line change 9393 <%= strip_tags ( post . rendered_description . to_html ) %>
9494 </ div >
9595 < div class ="col-sm-1 ">
96- <%= link_to glyph ( :time ) ,
97- give_time_user_path ( @user , offer : post . id ) ,
98- title : t ( "global.give_time" ) %>
96+ <% if @user != current_user %>
97+ <%= link_to give_time_user_path ( @user , offer : post . id ) do %>
98+ <%= glyph :time %>
99+ <% end %>
100+ <% end %>
99101 </ div >
100102 </ div >
101103 <% end %>
Original file line number Diff line number Diff line change 102102 attributes :
103103 web :
104104 url_format_invalid : Format de URL no vàlid
105+ transfer :
106+ attributes :
107+ base :
108+ same_account : No es pot fer una transacció al mateix compte
105109
106110 # ETIQUETAS VARIADAS EN PLANTILLAS
107111
Original file line number Diff line number Diff line change 102102 attributes :
103103 web :
104104 url_format_invalid : invalid URL format
105+ transfer :
106+ attributes :
107+ base :
108+ same_account : A transfer cannot be made to the same account
105109
106110 # ETIQUETAS VARIADAS EN PLANTILLAS
107111
Original file line number Diff line number Diff line change 102102 attributes :
103103 web :
104104 url_format_invalid : Formato de URL no válido
105+ transfer :
106+ attributes :
107+ base :
108+ same_account : No se puede hacer una transacción a la misma cuenta
105109
106110 # ETIQUETAS VARIADAS EN PLANTILLAS
107111
You can’t perform that action at this time.
0 commit comments