This file contains hidden or 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 IssuesController < ApplicationController | |
default_search_scope :issues | |
before_filter :find_issue, :only => [:show, :edit, :update] | |
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] | |
before_filter :find_project, :only => [:new, :create, :update_form] | |
before_filter :authorize, :except => [:index] | |
before_filter :find_optional_project, :only => [:index] | |
before_filter :check_for_default_issue_status, :only => [:new, :create] | |
before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
OlderNewer