Defect #44361 ยป news_preview_cross_project.patch
| app/controllers/previews_controller.rb | ||
|---|---|---|
| 47 | 47 | |
| 48 | 48 |
def find_project |
| 49 | 49 |
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id] |
| 50 |
@project = Project.find(project_id) |
|
| 50 |
@project = Project.find(project_id) if project_id.present?
|
|
| 51 | 51 |
rescue ActiveRecord::RecordNotFound |
| 52 | 52 |
render_404 |
| 53 | 53 |
end |
| test/functional/previews_controller_test.rb | ||
|---|---|---|
| 109 | 109 |
assert_select 'p', :text => /News description/ |
| 110 | 110 |
end |
| 111 | 111 | |
| 112 |
def test_preview_new_news_without_project_should_be_successful |
|
| 113 |
@request.session[:user_id] = 2 |
|
| 114 |
post( |
|
| 115 |
:news, |
|
| 116 |
:params => {
|
|
| 117 |
:text => 'News description', |
|
| 118 |
} |
|
| 119 |
) |
|
| 120 |
assert_response :success |
|
| 121 |
assert_select 'p', :text => /News description/ |
|
| 122 |
end |
|
| 123 | ||
| 124 |
def test_preview_news_with_invalid_project_should_return_404 |
|
| 125 |
@request.session[:user_id] = 2 |
|
| 126 |
post( |
|
| 127 |
:news, |
|
| 128 |
:params => {
|
|
| 129 |
:project_id => 'invalid', |
|
| 130 |
:text => 'News description', |
|
| 131 |
} |
|
| 132 |
) |
|
| 133 |
assert_response :not_found |
|
| 134 |
end |
|
| 135 | ||
| 112 | 136 |
def test_preview_existing_news |
| 113 | 137 |
get( |
| 114 | 138 |
:news, |