This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today) | |
@time_entry.safe_attributes = params[:time_entry] | |
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) | |
if @time_entry.save | |
respond_to do |format| | |
format.html { | |
flash[:notice] = l(:notice_successful_create) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
CreateTimeEntryService.new(self).call() | |
end | |
class CreateTimeEntryService < SimpleDelegator | |
def initialize(parent) | |
super(parent) | |
end | |
def call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
if issue_id.present? | |
log_time_on_issue | |
else | |
log_time_on_project | |
end | |
end | |
def log_time_on_project | |
log_time(nil, project_id) { do_log_time_on_project } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CUSTOM EXCEPTIONS | |
class CallAlreadyInProgress < StandardError | |
end | |
class Dialer | |
def call(number) | |
raise CallAlreadyInProgress.new if call_already_in_progress? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
begin | |
PublishBlogPost.new.call(post_id) | |
rescue BlogPostNotFound | |
redirect_to foo | |
rescue AlreadyPublished | |
flash[:error] = already_plublished_message | |
render :foo | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class MainTest < ActionDispatch::IntegrationTest | |
def test_main | |
#index looks ok | |
get '/' | |
assert_tag(:a, child: "New Post") | |
assert_select("a[href=/posts/new]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PicturesController < ApplicationController | |
def index | |
if confirm_params_or_redirect(params) | |
redirect_to root_path(:view => @view, :filter => @filter) and return | |
end | |
Picture.find(@view, @filter) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_file_from_disk(self): | |
first_time = False | |
if not os.path.exists(CONFIG_DIR): | |
os.mkdir(CONFIG_DIR) | |
first_time = True | |
if not os.path.exists(DIARY_FILE): | |
file = open(DIARY_FILE, 'w') | |
file.close() | |
first_time = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Artist creates an art work | |
Given I am a registered artist | |
And I follow the add new artwork link from the dashboard | |
When I fill the form with the artwork data | |
And I upload a picture | |
Then I should see a confirmation message telling me that the artwork was added to my collection | |
scenario "artist creates an art work" do | |
artist = TestUser.new | |
artist.go_to_new_artwork_page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
class KeyTest < Test::Unit::TestCase | |
def test_key | |
object = Object.new | |
assert_equal(:submit, object_key(object)) | |
def object.persisted?; true end | |
assert_equal(:update, object_key(object)) |
OlderNewer