Commit 1756f2aa63ae5037c31eaa1f462368f999bbfdc1
1 parent
ad2b99ba
Exists in
software_as_organization
Upadate functional tests
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Gustavo Coelho <gust.rod.coelho@gmail.com>
Showing
10 changed files
with
214 additions
and
148 deletions
Show diff stats
src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb
... | ... | @@ -7,16 +7,19 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
7 | 7 | def new_software |
8 | 8 | set_software_as_template |
9 | 9 | |
10 | - @community = Community.new(params[:community]) | |
11 | - @community.environment = environment | |
10 | + @software = Software.new(params[:software]) | |
11 | + @software.environment = environment | |
12 | 12 | |
13 | 13 | @license_info = LicenseInfo.find_by_id(params[:license][:license_infos_id]) if params[:license] |
14 | 14 | @license_info ||= LicenseInfo.new |
15 | 15 | |
16 | 16 | @software_info = SoftwareInfo.new(params[:software_info]) |
17 | - @software_info.community = @community | |
17 | + @software_info.software = @software | |
18 | 18 | @software_info.license_info = @license_info |
19 | 19 | |
20 | + @software.software_info = @software_info | |
21 | + @software_info.software = @software | |
22 | + | |
20 | 23 | control_software_creation |
21 | 24 | update_new_software_errors |
22 | 25 | end |
... | ... | @@ -36,8 +39,8 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
36 | 39 | raise NotAdminException unless can_change_public_software? |
37 | 40 | @software_info.update_attributes!(params[:software]) |
38 | 41 | |
39 | - @community = @software_info.community | |
40 | - @community.update_attributes!(params[:community]) | |
42 | + @software = @software_info.software | |
43 | + @software.update_attributes!(params[:community]) | |
41 | 44 | |
42 | 45 | if params[:commit] == _('Save and Configure Community') |
43 | 46 | redirect_to :controller => 'profile_editor', :action => 'edit' |
... | ... | @@ -70,10 +73,10 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
70 | 73 | |
71 | 74 | def add_software_erros |
72 | 75 | @errors = [] |
73 | - if @community | |
74 | - error = @community.errors.delete(:identifier) | |
76 | + if @software | |
77 | + error = @software.errors.delete(:identifier) | |
75 | 78 | @errors |= [_("Domain %s") % error.first ] if error |
76 | - @errors |= @community.errors.full_messages | |
79 | + @errors |= @software.errors.full_messages | |
77 | 80 | end |
78 | 81 | @errors |= @software_info.errors.full_messages if @software_info |
79 | 82 | @errors |= @license_info.errors.full_messages if @license_info |
... | ... | @@ -81,7 +84,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
81 | 84 | |
82 | 85 | def control_software_creation |
83 | 86 | if request.post? |
84 | - valid_models = @community.valid? | |
87 | + valid_models = @software.valid? | |
85 | 88 | valid_models &= @software_info.valid? |
86 | 89 | valid_models &= @license_info.valid? |
87 | 90 | if valid_models |
... | ... | @@ -135,9 +138,9 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
135 | 138 | @software_info = SoftwareInfo.create_after_moderation(user, |
136 | 139 | params[:software_info].merge({ |
137 | 140 | :environment => environment, |
138 | - :name => params[:community][:name], | |
139 | - :identifier => params[:community][:identifier], | |
140 | - :image_builder => params[:community][:image_builder], | |
141 | + :name => params[:software][:name], | |
142 | + :identifier => params[:software][:identifier], | |
143 | + :image_builder => params[:software][:image_builder], | |
141 | 144 | :license_info => @license_info, |
142 | 145 | :another_license_version => another_license_version, |
143 | 146 | :another_license_link => another_license_link })) |
... | ... | @@ -151,7 +154,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
151 | 154 | else |
152 | 155 | redirect_to :controller => 'profile_editor', |
153 | 156 | :action => 'edit', |
154 | - :profile => @community.identifier | |
157 | + :profile => @software.identifier | |
155 | 158 | end |
156 | 159 | end |
157 | 160 | |
... | ... | @@ -188,23 +191,23 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
188 | 191 | unless params[:q].nil? |
189 | 192 | admins = params[:q].split(/,/).map{ |n| environment.people.find n.to_i } |
190 | 193 | admins.each do |admin| |
191 | - @community.add_member(admin) | |
192 | - @community.add_admin(admin) | |
194 | + @software.add_member(admin) | |
195 | + @software.add_admin(admin) | |
193 | 196 | end |
194 | 197 | end |
195 | 198 | end |
196 | 199 | |
197 | 200 | def update_new_software_errors |
198 | 201 | if request.post? |
199 | - @community.valid? if @community | |
202 | + @software.valid? if @software | |
200 | 203 | @software_info.valid? if @software_info |
201 | 204 | @license_info.valid? if @license_info |
202 | 205 | add_software_erros |
203 | 206 | end |
204 | 207 | |
205 | - @error_community_name = @community.errors.include?(:name) ? "highlight-error" : "" if @community | |
208 | + @error_software_name = @software.errors.include?(:name) ? "highlight-error" : "" if @software | |
206 | 209 | @error_software_acronym = @software_info.errors.include?(:acronym) ? "highlight-error" : "" if @software_info |
207 | - @error_software_domain = @community.errors.include?(:identifier) ? "highlight-error" : "" if @community | |
210 | + @error_software_domain = @software.errors.include?(:identifier) ? "highlight-error" : "" if @software | |
208 | 211 | @error_software_finality = @software_info.errors.include?(:finality) ? "highlight-error" : "" if @software_info |
209 | 212 | @error_software_license = @license_info.errors.include?(:version) ? "highlight-error" : "" if @license_info |
210 | 213 | end | ... | ... |
src/noosfero-spb/software_communities/lib/create_software.rb
... | ... | @@ -34,10 +34,10 @@ class CreateSoftware < Task |
34 | 34 | software_info = SoftwareInfo.new(:finality => self.finality, |
35 | 35 | :repository_link => self.repository_link, |
36 | 36 | :license_info => self.license_info) |
37 | - software_info.verify_license_info(self.another_license_version, self.another_license_link) | |
38 | 37 | |
39 | 38 | software_info.software = software |
40 | 39 | software.software_info = software_info |
40 | + software_info.verify_license_info(self.another_license_version, self.another_license_link) | |
41 | 41 | software.save! |
42 | 42 | |
43 | 43 | software.environment = self.environment | ... | ... |
src/noosfero-spb/software_communities/lib/ext/search_controller.rb
... | ... | @@ -128,7 +128,7 @@ class SearchController |
128 | 128 | categories = Category.software_categories |
129 | 129 | |
130 | 130 | categories.each do |category| |
131 | - if category.software_infos.count > 0 | |
131 | + if category.softwares.count > 0 | |
132 | 132 | @enabled_check_box[category] = :enabled |
133 | 133 | else |
134 | 134 | @enabled_check_box[category] = :disabled | ... | ... |
src/noosfero-spb/software_communities/lib/software.rb
... | ... | @@ -5,6 +5,15 @@ class Software < Organization |
5 | 5 | :nickname => 3 |
6 | 6 | } |
7 | 7 | |
8 | + SEARCH_FILTERS = { | |
9 | + :order => %w[], | |
10 | + :display => %w[full] | |
11 | + } | |
12 | + | |
13 | + def self.default_search_display | |
14 | + 'full' | |
15 | + end | |
16 | + | |
8 | 17 | settings_items :hits, :type => :integer, :default => 0 |
9 | 18 | |
10 | 19 | has_one :software_info | ... | ... |
src/noosfero-spb/software_communities/test/functional/search_controller_test.rb
... | ... | @@ -27,46 +27,46 @@ class SearchControllerTest < ActionController::TestCase |
27 | 27 | |
28 | 28 | create_software_categories |
29 | 29 | |
30 | - @softwares = [] | |
30 | + @software_infos = [] | |
31 | 31 | |
32 | - @softwares << create_software_info("Software One", :acronym => "SFO", :finality => "Help") | |
33 | - @softwares << create_software_info("Software Two", :acronym => "SFT", :finality => "Task") | |
32 | + @software_infos << create_software_info("Software One", :acronym => "SFO", :finality => "Help") | |
33 | + @software_infos << create_software_info("Software Two", :acronym => "SFT", :finality => "Task") | |
34 | 34 | |
35 | - @softwares[0].community.categories << Category.first | |
36 | - @softwares[1].community.categories << Category.last | |
35 | + @software_infos[0].software.categories << Category.first | |
36 | + @software_infos[1].software.categories << Category.last | |
37 | 37 | |
38 | - @softwares[0].license_info = @licenses.first | |
39 | - @softwares[1].license_info = @licenses.last | |
38 | + @software_infos[0].license_info = @licenses.first | |
39 | + @software_infos[1].license_info = @licenses.last | |
40 | 40 | |
41 | - @softwares[0].save! | |
42 | - @softwares[1].save! | |
41 | + @software_infos[0].save! | |
42 | + @software_infos[1].save! | |
43 | 43 | end |
44 | 44 | |
45 | 45 | should "communities searches don't have software" do |
46 | - community = create_community("Community One") | |
46 | + community = fast_create(Community, :name => "Community One") | |
47 | 47 | |
48 | 48 | get :communities, :query => "One" |
49 | 49 | |
50 | 50 | assert_includes assigns(:searches)[:communities][:results], community |
51 | - assert_not_includes assigns(:searches)[:communities][:results], @softwares.first.community | |
51 | + assert_not_includes assigns(:searches)[:communities][:results], @software_infos.first.software | |
52 | 52 | end |
53 | 53 | |
54 | 54 | should "software_infos search don't have community" do |
55 | - community = create_community("Community One") | |
55 | + community = fast_create(Community, :name => "Community One") | |
56 | 56 | |
57 | 57 | get :software_infos, :query => "One" |
58 | 58 | |
59 | - assert_includes assigns(:searches)[:software_infos][:results], @softwares.first.community | |
59 | + assert_includes assigns(:searches)[:software_infos][:results], @software_infos.first.software | |
60 | 60 | assert_not_includes assigns(:searches)[:software_infos][:results], community |
61 | 61 | end |
62 | 62 | |
63 | 63 | |
64 | 64 | should "Don't have template in communities search result" do |
65 | 65 | communities = [] |
66 | - communities << create_community("Community One") | |
67 | - communities << create_community("Community Two") | |
66 | + communities << fast_create(Community,:name => "Community One") | |
67 | + communities << fast_create(Community,:name => "Community Two") | |
68 | 68 | |
69 | - community_template = create_community("Community Template") | |
69 | + community_template = fast_create(Community,:name => "Community Template") | |
70 | 70 | community_template.is_template = true |
71 | 71 | community_template.visible = false |
72 | 72 | community_template.save! |
... | ... | @@ -86,40 +86,40 @@ class SearchControllerTest < ActionController::TestCase |
86 | 86 | :selected_categories_id => [Category.first.id] |
87 | 87 | ) |
88 | 88 | |
89 | - assert_includes assigns(:searches)[:software_infos][:results], @softwares.first.community | |
90 | - assert_not_includes assigns(:searches)[:software_infos][:results], @softwares.last.community | |
89 | + assert_includes assigns(:searches)[:software_infos][:results], @software_infos.first.software | |
90 | + assert_not_includes assigns(:searches)[:software_infos][:results], @software_infos.last.software | |
91 | 91 | end |
92 | 92 | |
93 | 93 | should "software_infos search by programming language" do |
94 | - @softwares.first.software_languages << create_software_language("Python", "1.0") | |
95 | - @softwares.last.software_languages << create_software_language("Java", "8.1") | |
94 | + @software_infos.first.software_languages << create_software_language("Python", "1.0") | |
95 | + @software_infos.last.software_languages << create_software_language("Java", "8.1") | |
96 | 96 | |
97 | - @softwares.first.save! | |
98 | - @softwares.last.save! | |
97 | + @software_infos.first.save! | |
98 | + @software_infos.last.save! | |
99 | 99 | |
100 | 100 | get( |
101 | 101 | :software_infos, |
102 | 102 | :query => "python", |
103 | 103 | ) |
104 | 104 | |
105 | - assert_includes assigns(:searches)[:software_infos][:results], @softwares.first.community | |
106 | - assert_not_includes assigns(:searches)[:software_infos][:results], @softwares.last.community | |
105 | + assert_includes assigns(:searches)[:software_infos][:results], @software_infos.first.software | |
106 | + assert_not_includes assigns(:searches)[:software_infos][:results], @software_infos.last.software | |
107 | 107 | end |
108 | 108 | |
109 | 109 | should "software_infos search by database description" do |
110 | - @softwares.first.software_databases << create_software_database("MySQL", "1.0") | |
111 | - @softwares.last.software_databases << create_software_database("Postgrees", "8.1") | |
110 | + @software_infos.first.software_databases << create_software_database("MySQL", "1.0") | |
111 | + @software_infos.last.software_databases << create_software_database("Postgrees", "8.1") | |
112 | 112 | |
113 | - @softwares.first.save! | |
114 | - @softwares.last.save! | |
113 | + @software_infos.first.save! | |
114 | + @software_infos.last.save! | |
115 | 115 | |
116 | 116 | get( |
117 | 117 | :software_infos, |
118 | 118 | :query => "mysql", |
119 | 119 | ) |
120 | 120 | |
121 | - assert_includes assigns(:searches)[:software_infos][:results], @softwares.first.community | |
122 | - assert_not_includes assigns(:searches)[:software_infos][:results], @softwares.last.community | |
121 | + assert_includes assigns(:searches)[:software_infos][:results], @software_infos.first.software | |
122 | + assert_not_includes assigns(:searches)[:software_infos][:results], @software_infos.last.software | |
123 | 123 | end |
124 | 124 | |
125 | 125 | should "software_infos search by finality" do |
... | ... | @@ -129,8 +129,8 @@ class SearchControllerTest < ActionController::TestCase |
129 | 129 | ) |
130 | 130 | |
131 | 131 | |
132 | - assert_includes assigns(:searches)[:software_infos][:results], @softwares.first.community | |
133 | - assert_not_includes assigns(:searches)[:software_infos][:results], @softwares.last.community | |
132 | + assert_includes assigns(:searches)[:software_infos][:results], @software_infos.first.software | |
133 | + assert_not_includes assigns(:searches)[:software_infos][:results], @software_infos.last.software | |
134 | 134 | end |
135 | 135 | |
136 | 136 | should "software_infos search by acronym" do |
... | ... | @@ -139,20 +139,20 @@ class SearchControllerTest < ActionController::TestCase |
139 | 139 | :query => "SFO", |
140 | 140 | ) |
141 | 141 | |
142 | - assert_includes assigns(:searches)[:software_infos][:results], @softwares.first.community | |
143 | - assert_not_includes assigns(:searches)[:software_infos][:results], @softwares.last.community | |
142 | + assert_includes assigns(:searches)[:software_infos][:results], @software_infos.first.software | |
143 | + assert_not_includes assigns(:searches)[:software_infos][:results], @software_infos.last.software | |
144 | 144 | end |
145 | 145 | |
146 | 146 | should "software_infos search by relevance" do |
147 | - @softwares << create_software_info("Software Three", :acronym => "SFW", :finality => "Java") | |
148 | - @softwares.last.license_info = LicenseInfo.create :version => "GPL - 3.0" | |
147 | + @software_infos << create_software_info("Software Three", :acronym => "SFW", :finality => "Java") | |
148 | + @software_infos.last.license_info = LicenseInfo.create :version => "GPL - 3.0" | |
149 | 149 | |
150 | 150 | |
151 | - @softwares.first.software_languages << create_software_language("Java", "8.0") | |
152 | - @softwares.first.save! | |
151 | + @software_infos.first.software_languages << create_software_language("Java", "8.0") | |
152 | + @software_infos.first.save! | |
153 | 153 | |
154 | - @softwares[1].community.name = "Java" | |
155 | - @softwares[1].community.save! | |
154 | + @software_infos[1].software.name = "Java" | |
155 | + @software_infos[1].software.save! | |
156 | 156 | |
157 | 157 | get( |
158 | 158 | :software_infos, |
... | ... | @@ -160,43 +160,43 @@ class SearchControllerTest < ActionController::TestCase |
160 | 160 | :query => "Java" |
161 | 161 | ) |
162 | 162 | |
163 | - assert_equal assigns(:searches)[:software_infos][:results][0], @softwares[1].community | |
164 | - assert_equal assigns(:searches)[:software_infos][:results][1], @softwares[2].community | |
165 | - assert_equal assigns(:searches)[:software_infos][:results][2], @softwares[0].community | |
163 | + assert_equal assigns(:searches)[:software_infos][:results][0], @software_infos[1].software | |
164 | + assert_equal assigns(:searches)[:software_infos][:results][1], @software_infos[2].software | |
165 | + assert_equal assigns(:searches)[:software_infos][:results][2], @software_infos[0].software | |
166 | 166 | end |
167 | 167 | |
168 | 168 | should "software_infos search only public_software" do |
169 | - software_one = create_software_info("Software One", :acronym => "SFO", :finality => "Help") | |
170 | - software_two = create_software_info("Java", :acronym => "SFT", :finality => "Task") | |
171 | - software_three = create_software_info("Software Three", :acronym => "SFW", :finality => "Java") | |
172 | - software_three.public_software = false | |
173 | - software_three.save! | |
169 | + software_info_one = create_software_info("Software One", :acronym => "SFO", :finality => "Help") | |
170 | + software_info_two = create_software_info("Java", :acronym => "SFT", :finality => "Task") | |
171 | + software_info_three = create_software_info("Software Three", :acronym => "SFW", :finality => "Java") | |
172 | + software_info_three.public_software = false | |
173 | + software_info_three.save! | |
174 | 174 | |
175 | 175 | get( |
176 | 176 | :software_infos, |
177 | 177 | :software_type => "public_software" |
178 | 178 | ) |
179 | 179 | |
180 | - assert_includes assigns(:searches)[:software_infos][:results], software_one.community | |
181 | - assert_includes assigns(:searches)[:software_infos][:results], software_two.community | |
182 | - assert_not_includes assigns(:searches)[:software_infos][:results], software_three.community | |
180 | + assert_includes assigns(:searches)[:software_infos][:results], software_info_one.software | |
181 | + assert_includes assigns(:searches)[:software_infos][:results], software_info_two.software | |
182 | + assert_not_includes assigns(:searches)[:software_infos][:results], software_info_three.software | |
183 | 183 | end |
184 | 184 | |
185 | 185 | should "software_infos search public_software and other all" do |
186 | - software_one = create_software_info("Software One", :acronym => "SFO", :finality => "Help") | |
187 | - software_two = create_software_info("Java", :acronym => "SFT", :finality => "Task") | |
188 | - software_three = create_software_info("Software Three", :acronym => "SFW", :finality => "Java") | |
189 | - software_three.public_software = false | |
190 | - software_three.save! | |
186 | + software_info_one = create_software_info("Software One", :acronym => "SFO", :finality => "Help") | |
187 | + software_info_two = create_software_info("Java", :acronym => "SFT", :finality => "Task") | |
188 | + software_info_three = create_software_info("Software Three", :acronym => "SFW", :finality => "Java") | |
189 | + software_info_three.public_software = false | |
190 | + software_info_three.save! | |
191 | 191 | |
192 | 192 | get( |
193 | 193 | :software_infos, |
194 | 194 | :software_type => "all" |
195 | 195 | ) |
196 | 196 | |
197 | - assert_includes assigns(:searches)[:software_infos][:results], software_one.community | |
198 | - assert_includes assigns(:searches)[:software_infos][:results], software_two.community | |
199 | - assert_includes assigns(:searches)[:software_infos][:results], software_three.community | |
197 | + assert_includes assigns(:searches)[:software_infos][:results], software_info_one.software | |
198 | + assert_includes assigns(:searches)[:software_infos][:results], software_info_two.software | |
199 | + assert_includes assigns(:searches)[:software_infos][:results], software_info_three.software | |
200 | 200 | end |
201 | 201 | |
202 | 202 | should "software_infos search return only the software in params" do |
... | ... | @@ -209,9 +209,9 @@ class SearchControllerTest < ActionController::TestCase |
209 | 209 | :only_softwares => ["software-three", "java"] |
210 | 210 | ) |
211 | 211 | |
212 | - assert_includes assigns(:searches)[:software_infos][:results], software_two.community | |
213 | - assert_includes assigns(:searches)[:software_infos][:results], software_three.community | |
214 | - assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community | |
212 | + assert_includes assigns(:searches)[:software_infos][:results], software_two.software | |
213 | + assert_includes assigns(:searches)[:software_infos][:results], software_three.software | |
214 | + assert_not_includes assigns(:searches)[:software_infos][:results], software_one.software | |
215 | 215 | end |
216 | 216 | |
217 | 217 | should "software_infos search return only enabled softwares" do |
... | ... | @@ -224,10 +224,10 @@ class SearchControllerTest < ActionController::TestCase |
224 | 224 | :query => "software" |
225 | 225 | ) |
226 | 226 | |
227 | - assert_includes assigns(:searches)[:software_infos][:results], s1.community | |
228 | - assert_includes assigns(:searches)[:software_infos][:results], s2.community | |
227 | + assert_includes assigns(:searches)[:software_infos][:results], s1.software | |
228 | + assert_includes assigns(:searches)[:software_infos][:results], s2.software | |
229 | 229 | |
230 | - s2.community.disable | |
230 | + s2.software.disable | |
231 | 231 | |
232 | 232 | # Now it should not contain the disabled community |
233 | 233 | get( |
... | ... | @@ -235,25 +235,26 @@ class SearchControllerTest < ActionController::TestCase |
235 | 235 | :query => "software" |
236 | 236 | ) |
237 | 237 | |
238 | - assert_includes assigns(:searches)[:software_infos][:results], s1.community | |
239 | - assert_not_includes assigns(:searches)[:software_infos][:results], s2.community | |
238 | + assert_includes assigns(:searches)[:software_infos][:results], s1.software | |
239 | + assert_not_includes assigns(:searches)[:software_infos][:results], s2.software | |
240 | 240 | end |
241 | 241 | |
242 | 242 | should "software_infos search not return software with secret community" do |
243 | - software_one = create_software_info("Software ABC", :acronym => "SFO", :finality => "Help") | |
244 | - software_two = create_software_info("Python", :acronym => "SFT", :finality => "Task") | |
245 | - software_three = create_software_info("Software DEF", :acronym => "SFW", :finality => "Java") | |
243 | + software_info_one = create_software_info("Software ABC", :acronym => "SFO", :finality => "Help") | |
244 | + software_info_two = create_software_info("Python", :acronym => "SFT", :finality => "Task") | |
245 | + software_info_three = create_software_info("Software DEF", :acronym => "SFW", :finality => "Java") | |
246 | 246 | |
247 | - software_one.community.secret = true | |
248 | - software_one.community.save! | |
247 | + software_info_one.software.secret = true | |
248 | + software_info_one.software.save! | |
249 | 249 | |
250 | 250 | get( |
251 | 251 | :software_infos, |
252 | 252 | ) |
253 | 253 | |
254 | - assert_includes assigns(:searches)[:software_infos][:results], software_two.community | |
255 | - assert_includes assigns(:searches)[:software_infos][:results], software_three.community | |
256 | - assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community | |
254 | + assert_includes assigns(:searches)[:software_infos][:results], software_info_two.software | |
255 | + assert_includes assigns(:searches)[:software_infos][:results], software_info_three.software | |
256 | + assert_not_includes assigns(:searches)[:software_infos][:results], software_info_one.software | |
257 | + | |
257 | 258 | end |
258 | 259 | |
259 | 260 | private | ... | ... |
src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb
... | ... | @@ -37,10 +37,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
37 | 37 | |
38 | 38 | should 'Add offer to admin in new software' do |
39 | 39 | @hash_list = software_fields |
40 | - @software = create_software @hash_list | |
41 | - @software.community.add_admin(@offer.person) | |
42 | - @software.save | |
43 | - assert_equal @offer.person.id, @software.community.admins.last.id | |
40 | + @software_info = create_software @hash_list | |
41 | + @software_info.software.add_admin(@offer.person) | |
42 | + @software_info.save | |
43 | + assert_equal @offer.person.id, @software_info.software.admins.last.id | |
44 | 44 | end |
45 | 45 | |
46 | 46 | should 'create a new software with all fields filled in' do |
... | ... | @@ -49,21 +49,21 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
49 | 49 | post( |
50 | 50 | :new_software, |
51 | 51 | :profile => @person.identifier, |
52 | - :community => fields[1], | |
52 | + :software => fields[1], | |
53 | 53 | :license => fields[0], |
54 | 54 | :software_info => fields[2] |
55 | 55 | ) |
56 | - assert_equal SoftwareInfo.last.community.name, "Debian" | |
56 | + assert_equal SoftwareInfo.last.software.name, "Debian" | |
57 | 57 | end |
58 | 58 | |
59 | 59 | should 'edit a new software adding basic information' do |
60 | 60 | fields_software = software_fields |
61 | 61 | fields = software_edit_basic_fields |
62 | 62 | |
63 | - software = create_software fields_software | |
63 | + software_info = create_software fields_software | |
64 | 64 | post( |
65 | 65 | :edit_software, |
66 | - :profile => software.community.identifier, | |
66 | + :profile => software_info.software.identifier, | |
67 | 67 | :license => fields[1], |
68 | 68 | :software => fields[0], |
69 | 69 | :library => {}, |
... | ... | @@ -78,10 +78,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
78 | 78 | fields_software = software_fields |
79 | 79 | fields = software_edit_specific_fields |
80 | 80 | |
81 | - software = create_software fields_software | |
81 | + software_info = create_software fields_software | |
82 | 82 | post( |
83 | 83 | :edit_software, |
84 | - :profile => software.community.identifier, | |
84 | + :profile => software_info.software.identifier, | |
85 | 85 | :library => fields[0], |
86 | 86 | :language => fields[1], |
87 | 87 | :database => fields[2], |
... | ... | @@ -101,11 +101,11 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
101 | 101 | fields = software_edit_specific_fields |
102 | 102 | |
103 | 103 | fields[4]['public_software'] = true |
104 | - software = create_software fields_software | |
104 | + software_info = create_software fields_software | |
105 | 105 | |
106 | 106 | post( |
107 | 107 | :edit_software, |
108 | - :profile => software.community.identifier, | |
108 | + :profile => software_info.software.identifier, | |
109 | 109 | :operating_system => fields[3], |
110 | 110 | :software => fields[4], |
111 | 111 | ) |
... | ... | @@ -118,11 +118,11 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
118 | 118 | fields = software_edit_specific_fields |
119 | 119 | |
120 | 120 | fields[4]['public_software'] = true |
121 | - software = create_software fields_software | |
121 | + software_info = create_software fields_software | |
122 | 122 | |
123 | 123 | post( |
124 | 124 | :edit_software, |
125 | - :profile => software.community.identifier, | |
125 | + :profile => software_info.software.identifier, | |
126 | 126 | :software => fields[4] |
127 | 127 | ) |
128 | 128 | |
... | ... | @@ -136,11 +136,11 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
136 | 136 | |
137 | 137 | fields[4][attr]=true |
138 | 138 | |
139 | - software = create_software fields_software | |
139 | + software_info = create_software fields_software | |
140 | 140 | |
141 | 141 | post( |
142 | 142 | :edit_software, |
143 | - :profile => software.community.identifier, | |
143 | + :profile => software_info.software.identifier, | |
144 | 144 | :software => fields[4] |
145 | 145 | ) |
146 | 146 | |
... | ... | @@ -159,11 +159,11 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
159 | 159 | |
160 | 160 | fields[4][attr]=true |
161 | 161 | |
162 | - software = create_software fields_software | |
162 | + software_info = create_software fields_software | |
163 | 163 | |
164 | 164 | post( |
165 | 165 | :edit_software, |
166 | - :profile => software.community.identifier, | |
166 | + :profile => software_info.software.identifier, | |
167 | 167 | :software => fields[4] |
168 | 168 | ) |
169 | 169 | |
... | ... | @@ -176,7 +176,7 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
176 | 176 | |
177 | 177 | post( |
178 | 178 | :new_software, |
179 | - :community => {:name =>"New Software", :identifier => "new-software"}, | |
179 | + :software => {:name =>"New Software", :identifier => "new-software"}, | |
180 | 180 | :software_info => {:finality => "something", :repository_link => ""}, |
181 | 181 | :license =>{:license_infos_id => LicenseInfo.last.id}, |
182 | 182 | :profile => @person.identifier |
... | ... | @@ -194,7 +194,7 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
194 | 194 | |
195 | 195 | post( |
196 | 196 | :new_software, |
197 | - :community => { :name => "New Software", :identifier => "new-software" }, | |
197 | + :software => { :name => "New Software", :identifier => "new-software" }, | |
198 | 198 | :software_info => { :finality => "something", :repository_link => "" }, |
199 | 199 | :license => { :license_infos_id => license_another.id, |
200 | 200 | :version => another_license_version, |
... | ... | @@ -217,7 +217,7 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
217 | 217 | |
218 | 218 | post( |
219 | 219 | :new_software, |
220 | - :community => { :name => "New Software", :identifier => "new-software" }, | |
220 | + :software => { :name => "New Software", :identifier => "new-software" }, | |
221 | 221 | :software_info => { :finality => "something", :repository_link => "" }, |
222 | 222 | :license => { :license_infos_id => license_another.id, |
223 | 223 | :version => another_license_version, |
... | ... | @@ -238,7 +238,7 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
238 | 238 | should "show error messages on create software_info" do |
239 | 239 | post( |
240 | 240 | :new_software, |
241 | - :community => {}, | |
241 | + :software => {}, | |
242 | 242 | :software_info => {}, |
243 | 243 | :license => {}, |
244 | 244 | :profile => @person.identifier |
... | ... | @@ -254,14 +254,14 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
254 | 254 | |
255 | 255 | post( |
256 | 256 | :new_software, |
257 | - :community => {:name =>"New Software", :identifier => "new-software"}, | |
257 | + :software => {:name =>"New Software", :identifier => "new-software"}, | |
258 | 258 | :software_info => {:finality => "something", :repository_link => ""}, |
259 | 259 | :license =>{:license_infos_id => LicenseInfo.last.id}, |
260 | 260 | :profile => @person.identifier |
261 | 261 | ) |
262 | 262 | post( |
263 | 263 | :new_software, |
264 | - :community => {:name =>"New Software", :identifier => "new-software"}, | |
264 | + :software => {:name =>"New Software", :identifier => "new-software"}, | |
265 | 265 | :software_info => {:finality => "something", :repository_link => ""}, |
266 | 266 | :license =>{:license_infos_id => LicenseInfo.last.id}, |
267 | 267 | :profile => @person.identifier |
... | ... | @@ -275,7 +275,7 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
275 | 275 | |
276 | 276 | post( |
277 | 277 | :new_software, |
278 | - :community => {:name =>"New Software", :identifier => "new-software"}, | |
278 | + :software => {:name =>"New Software", :identifier => "new-software"}, | |
279 | 279 | :software_info => {:finality => "something", :repository_link => ""}, |
280 | 280 | :license =>{:license_infos_id => LicenseInfo.last.id}, |
281 | 281 | :profile => @person.identifier |
... | ... | @@ -285,14 +285,14 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
285 | 285 | Task.last.send('finish', @person) |
286 | 286 | |
287 | 287 | assert_equal "New Software", Task.last.data[:name] |
288 | - assert_equal "New Software", SoftwareInfo.last.community.name | |
288 | + assert_equal "New Software", SoftwareInfo.last.software.name | |
289 | 289 | end |
290 | 290 | |
291 | 291 | should "dont create software without accept task" do |
292 | 292 | assert_no_difference 'SoftwareInfo.count' do |
293 | 293 | post( |
294 | 294 | :new_software, |
295 | - :community => {:name =>"New Software", :identifier => "new-software"}, | |
295 | + :software => {:name =>"New Software", :identifier => "new-software"}, | |
296 | 296 | :software_info => {:finality => "something", :repository_link => ""}, |
297 | 297 | :license =>{:license_infos_id => LicenseInfo.last.id}, |
298 | 298 | :profile => @person.identifier | ... | ... |
src/noosfero-spb/software_communities/test/functional/software_communities_plugin_profile_controller_test.rb
... | ... | @@ -29,20 +29,20 @@ class SoftwareCommunitiesPluginProfileControllerTest < ActionController::TestCas |
29 | 29 | :total_downloads=>0 |
30 | 30 | } |
31 | 31 | |
32 | - @software = create_software(software_fields) | |
33 | - @software.save! | |
32 | + @software_info = create_software(software_fields) | |
33 | + @software_info.save! | |
34 | 34 | |
35 | 35 | download_block = DownloadBlock.new |
36 | 36 | download_block.downloads = Download.validate_download_list([@download_data]) |
37 | 37 | download_block.save! |
38 | 38 | |
39 | - @software.community.blocks << download_block | |
40 | - @software.community.save! | |
39 | + @software_info.software.blocks << download_block | |
40 | + @software_info.software.save! | |
41 | 41 | end |
42 | 42 | |
43 | 43 | should 'redirect to download link with correct params' do |
44 | 44 | download_block = DownloadBlock.last |
45 | - get :download_file, :profile=>@software.community.identifier, | |
45 | + get :download_file, :profile=>@software_info.software.identifier, | |
46 | 46 | :block => download_block.id, :download_index => 0 |
47 | 47 | |
48 | 48 | assert_equal nil, session[:notice] |
... | ... | @@ -51,7 +51,7 @@ class SoftwareCommunitiesPluginProfileControllerTest < ActionController::TestCas |
51 | 51 | |
52 | 52 | should "notice when the download was not found" do |
53 | 53 | download_block = DownloadBlock.last |
54 | - get :download_file, :profile=>@software.community.identifier, | |
54 | + get :download_file, :profile=>@software_info.software.identifier, | |
55 | 55 | :block => 123, :download_index => 0 |
56 | 56 | |
57 | 57 | assert_equal "Could not find the download file", session[:notice] |
... | ... | @@ -59,7 +59,7 @@ class SoftwareCommunitiesPluginProfileControllerTest < ActionController::TestCas |
59 | 59 | |
60 | 60 | should "notice when given invalid download params" do |
61 | 61 | download_block = DownloadBlock.last |
62 | - get :download_file, :profile=>@software.community.identifier, | |
62 | + get :download_file, :profile=>@software_info.software.identifier, | |
63 | 63 | :block => download_block.id, :download_index => -5 |
64 | 64 | |
65 | 65 | assert_equal "Invalid download params", session[:notice] | ... | ... |
src/noosfero-spb/software_communities/test/helpers/software_test_helper.rb
... | ... | @@ -64,27 +64,27 @@ module SoftwareTestHelper |
64 | 64 | |
65 | 65 | def create_software fields |
66 | 66 | |
67 | - software = SoftwareInfo.new | |
68 | - community = Community.new | |
69 | - software_hash = fields[2] | |
67 | + software_info = SoftwareInfo.new | |
68 | + software = Software.new | |
69 | + software_info_hash = fields[2] | |
70 | 70 | license_system_hash = fields[0] |
71 | - community_hash = fields[1] | |
71 | + software_hash = fields[1] | |
72 | 72 | |
73 | - software_hash.each do |k,v| | |
74 | - software[k] = v | |
73 | + software_info_hash.each do |k,v| | |
74 | + software_info[k] = v | |
75 | 75 | end |
76 | 76 | |
77 | - community_hash.each do |k,v| | |
78 | - community[k] = v | |
77 | + software_hash.each do |k,v| | |
78 | + software[k] = v | |
79 | 79 | end |
80 | 80 | |
81 | - community.save! | |
82 | - software.community = community | |
83 | - software.license_info_id = license_system_hash[:license_infos_id] | |
81 | + software_info.software = software | |
82 | + software_info.license_info_id = license_system_hash[:license_infos_id] | |
84 | 83 | |
84 | + software.software_info = software_info | |
85 | 85 | software.save! |
86 | 86 | |
87 | - software | |
87 | + software_info | |
88 | 88 | end |
89 | 89 | |
90 | 90 | def software_edit_basic_fields |
... | ... | @@ -190,4 +190,4 @@ module SoftwareTestHelper |
190 | 190 | end |
191 | 191 | end |
192 | 192 | #version: LicenseInfo.last.version, |
193 | -#id: LicenseInfo.last.id | |
194 | 193 | \ No newline at end of file |
194 | +#id: LicenseInfo.last.id | ... | ... |
src/noosfero-spb/software_communities/views/search/_full_software.html.erb
0 → 100644
... | ... | @@ -0,0 +1,53 @@ |
1 | +<% software_info = software.software_info %> | |
2 | +<li class="search-software_info-item"> | |
3 | + <div class="search-software_info-item-column-left"> | |
4 | + <%= profile_image_link software, :portrait, 'div', software.send(@order + '_label') + show_date(software.created_at) %> | |
5 | + </div> | |
6 | + | |
7 | + <div class="search-software_info-item-column-right"> | |
8 | + | |
9 | + <div class="search-software_info-content-block"> | |
10 | + <span> | |
11 | + <% link_name = software_info.acronym.blank? ? software.name : "#{software_info.acronym} - #{software.name}" %> | |
12 | + <h4> | |
13 | + <%= link_to_homepage(link_name, software.identifier) %> | |
14 | + </h4> | |
15 | + </span> | |
16 | + <span class="search-content-result"> | |
17 | + <% body_stripped = strip_tags(software_info.finality) %> | |
18 | + <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %> | |
19 | + </span> | |
20 | + </div> | |
21 | + | |
22 | + <br /> | |
23 | + | |
24 | + <div class="search-software_info-content-block"> | |
25 | + <span> | |
26 | + <b> | |
27 | + <%= _("software_info Categories") %>: | |
28 | + </b> | |
29 | + </span> | |
30 | + | |
31 | + <% if !software.categories.empty? %> | |
32 | + <ul id="categories-list"> | |
33 | + <% software.categories.each do |category| %> | |
34 | + <li> | |
35 | + <%= link_to _("#{category.name}"), { | |
36 | + :controller => :search, | |
37 | + :action => :software_infos, | |
38 | + :selected_categories_id => [category.id], | |
39 | + :software_info_type => params[:software_info_type] | |
40 | + } %> | |
41 | + </li> | |
42 | + <% end %> | |
43 | + </ul> | |
44 | + <% else %> | |
45 | + <span> | |
46 | + <%= _("This software_info doesn't have categories") %> | |
47 | + </span> | |
48 | + <% end %> | |
49 | + </div> | |
50 | + </div> | |
51 | + | |
52 | + <hr class="clearfix" /> | |
53 | +</li> | ... | ... |
src/noosfero-spb/software_communities/views/software_communities_plugin_myprofile/new_software.html.erb
... | ... | @@ -29,13 +29,13 @@ |
29 | 29 | <% end %> |
30 | 30 | |
31 | 31 | <div> |
32 | - <%= labelled_form_for :community, :html => { :multipart => true } do |f| %> | |
32 | + <%= labelled_form_for :software, :html => { :multipart => true } do |f| %> | |
33 | 33 | |
34 | 34 | <%= required_fields_message %> |
35 | 35 | |
36 | - <div class= <%= @error_community_name %> > | |
36 | + <div class= <%= @error_software_name %> > | |
37 | 37 | <%= label("name", _('Name'), {:class => 'formlabel mandatory'}) %> |
38 | - <%= required text_field(:community, :name, :size => 30, :maxlength => 100, :id => 'community_name_id') %> | |
38 | + <%= required text_field(:software, :name, :size => 30, :maxlength => 100, :id => 'software_name_id') %> | |
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <br> |
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 | <div id='software-name-field' class='formfield'> |
47 | 47 | |
48 | 48 | <span id='software-hostname'><%= environment.default_hostname %>/</span> |
49 | - <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100, :id => 'community-identifier') %> | |
49 | + <%= required text_field(:software, :identifier, :size => 30, :maxlength => 100, :id => 'software-identifier') %> | |
50 | 50 | </div> |
51 | 51 | </div> |
52 | 52 | |
... | ... | @@ -65,8 +65,8 @@ |
65 | 65 | </label> |
66 | 66 | </div> |
67 | 67 | <div id="profile_change_picture"> |
68 | - <%= f.fields_for :image_builder, @community.image do |i| %> | |
69 | - <%= file_field_or_thumbnail(_('Image:'), @community.image, i) %><%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %> | |
68 | + <%= f.fields_for :image_builder, @software.image do |i| %> | |
69 | + <%= file_field_or_thumbnail(_('Image:'), @software.image, i) %><%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %> | |
70 | 70 | <% end %> |
71 | 71 | </div> |
72 | 72 | ... | ... |