diff --git a/lib/common/models/wp_plugin.rb b/lib/common/models/wp_plugin.rb index e88b6481..0b1d8c10 100755 --- a/lib/common/models/wp_plugin.rb +++ b/lib/common/models/wp_plugin.rb @@ -3,8 +3,13 @@ class WpPlugin < WpItem include WpPlugin::Vulnerable + # Sets the @uri + # + # @param [ URI ] target_base_uri The URI of the wordpress blog + # + # @return [ void ] def forge_uri(target_base_uri) - @uri = target_base_uri.merge(URI.encode(wp_plugins_dir) + '/' + URI.encode(name) + '/') + @uri = target_base_uri.merge(URI.encode(wp_plugins_dir + '/' + name + '/')) end end diff --git a/spec/lib/common/models/wp_plugin_spec.rb b/spec/lib/common/models/wp_plugin_spec.rb new file mode 100644 index 00000000..7afe2ea0 --- /dev/null +++ b/spec/lib/common/models/wp_plugin_spec.rb @@ -0,0 +1,14 @@ +# encoding: UTF-8 + +require 'spec_helper' + +describe WpPlugin do + subject(:wp_plugin) { WpPlugin.new(uri, options) } + let(:uri) { URI.parse('http://example.com') } + let(:options) { { name: 'plugin-name' } } + + describe '#forge_uri' do + its('uri.to_s') { should == 'http://example.com/wp-content/plugins/plugin-name/' } + end + +end