Revision 912:5e80956cc792 .svn/pristine/12

View differences:

.svn/pristine/12/124c8ea6c27371f24076da94e97c521fc176d638.svn-base
1
require File.expand_path('../../test_helper', __FILE__)
2

  
3
class FilesControllerTest < ActionController::TestCase
4
  fixtures :projects, :trackers, :issue_statuses, :issues,
5
           :enumerations, :users, :issue_categories,
6
           :projects_trackers,
7
           :roles,
8
           :member_roles,
9
           :members,
10
           :enabled_modules,
11
           :workflows,
12
           :journals, :journal_details,
13
           :attachments,
14
           :versions
15

  
16
  def setup
17
    @controller = FilesController.new
18
    @request    = ActionController::TestRequest.new
19
    @response   = ActionController::TestResponse.new
20
    @request.session[:user_id] = nil
21
    Setting.default_language = 'en'
22
  end
23

  
24
  def test_index
25
    get :index, :project_id => 1
26
    assert_response :success
27
    assert_template 'index'
28
    assert_not_nil assigns(:containers)
29

  
30
    # file attached to the project
31
    assert_tag :a, :content => 'project_file.zip',
32
                   :attributes => { :href => '/attachments/download/8/project_file.zip' }
33

  
34
    # file attached to a project's version
35
    assert_tag :a, :content => 'version_file.zip',
36
                   :attributes => { :href => '/attachments/download/9/version_file.zip' }
37
  end
38

  
39
  def test_create_file
40
    set_tmp_attachments_directory
41
    @request.session[:user_id] = 2
42
    Setting.notified_events = ['file_added']
43
    ActionMailer::Base.deliveries.clear
44

  
45
    assert_difference 'Attachment.count' do
46
      post :create, :project_id => 1, :version_id => '',
47
           :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
48
      assert_response :redirect
49
    end
50
    assert_redirected_to '/projects/ecookbook/files'
51
    a = Attachment.find(:first, :order => 'created_on DESC')
52
    assert_equal 'testfile.txt', a.filename
53
    assert_equal Project.find(1), a.container
54

  
55
    mail = ActionMailer::Base.deliveries.last
56
    assert_kind_of TMail::Mail, mail
57
    assert_equal "[eCookbook] New file", mail.subject
58
    assert mail.body.include?('testfile.txt')
59
  end
60

  
61
  def test_create_version_file
62
    set_tmp_attachments_directory
63
    @request.session[:user_id] = 2
64
    Setting.notified_events = ['file_added']
65

  
66
    assert_difference 'Attachment.count' do
67
      post :create, :project_id => 1, :version_id => '2',
68
           :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
69
      assert_response :redirect
70
    end
71
    assert_redirected_to '/projects/ecookbook/files'
72
    a = Attachment.find(:first, :order => 'created_on DESC')
73
    assert_equal 'testfile.txt', a.filename
74
    assert_equal Version.find(2), a.container
75
  end
76

  
77
end
.svn/pristine/12/129a1be9ab4fb00e9e24a4a97d3003da6c507962.svn-base
1
<% if @project.boards.any? %>
2
<table class="list">
3
  <thead><tr>
4
    <th><%= l(:label_board) %></th>
5
    <th><%= l(:field_description) %></th>
6
    <th></th>
7
    <th></th>
8
  </tr></thead>
9
  <tbody>
10
<% @project.boards.each do |board|
11
  next if board.new_record? %>
12
  <tr class="<%= cycle 'odd', 'even' %>">
13
    <td><%=h board.name %></td>
14
    <td><%=h board.description %></td>
15
    <td align="center">
16
    <% if authorize_for("boards", "edit") %>
17
      <%= reorder_links('board', {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}) %>
18
    <% end %>
19
    </td>
20
    <td class="buttons">
21
      <%= link_to_if_authorized l(:button_edit), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}, :class => 'icon icon-edit' %>
22
      <%= link_to_if_authorized l(:button_delete), {:controller => 'boards', :action => 'destroy', :project_id => @project, :id => board}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
23
    </td>
24
  </tr>
25
<% end %>
26
  </tbody>
27
</table>
28
<% else %>
29
<p class="nodata"><%= l(:label_no_data) %></p>
30
<% end %>
31

  
32
<p><%= link_to_if_authorized l(:label_board_new), {:controller => 'boards', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %></p>
.svn/pristine/12/12d2aa017b97ff487eca5cc334afe4f6ec1d0dc6.svn-base
1
class NotifyMail < ActionMailer::Base
2

  
3
  helper :mail
4
  
5
  def signup(txt)
6
    body(:name => txt)
7
  end
8
  
9
  def multipart
10
    recipients 'some_address@email.com'
11
    subject    'multi part email'
12
    from       "another_user@email.com"
13
    content_type 'multipart/alternative'
14
    
15
    part :content_type => "text/html", :body => render_message("multipart_html", {})
16
    part "text/plain" do |p|
17
      p.body = render_message("multipart_plain", {})
18
    end
19
  end
20
  
21
  def implicit_multipart
22
    recipients 'some_address@email.com'
23
    subject    'multi part email'
24
    from       "another_user@email.com"
25
  end
26
end

Also available in: Unified diff